Hooked up changes in DisplayMenu
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7820 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: cbd9fdf41f10326eaae1ec0acf8015d1ec5922e1 Former-commit-id: 339baa896c5692b86d2cc65e0b9c4d29b2684979
This commit is contained in:
parent
2110c76afc
commit
7b37673511
2 changed files with 176 additions and 23 deletions
|
@ -30,8 +30,9 @@
|
||||||
|
|
||||||
// Some consts.
|
// Some consts.
|
||||||
static const char* ADisplayModes[DisplayMenu::nDisplayModes] = { "Full-screen", "Windowed" };
|
static const char* ADisplayModes[DisplayMenu::nDisplayModes] = { "Full-screen", "Windowed" };
|
||||||
static const char* MonitorTypes[DisplayMenu::nDisplayTypes] = { "None", "4:3", "16:9", "21:9" };
|
static const char* MonitorTypes[DisplayMenu::nDisplayTypes] = { "none", "4:3", "16:9", "21:9" };
|
||||||
static const char* SpansplitValues[] = { GR_VAL_NO, GR_VAL_YES };
|
static const char* SpansplitValues[] = { GR_VAL_NO, GR_VAL_YES };
|
||||||
|
static const int NbSpansplitValues = sizeof(SpansplitValues) / sizeof(SpansplitValues[0]);
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
static const int AMaxRefreshRates[] = { 0, 30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
|
static const int AMaxRefreshRates[] = { 0, 30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
|
||||||
static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefreshRates[0]);
|
static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefreshRates[0]);
|
||||||
|
@ -40,7 +41,10 @@ static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefres
|
||||||
// The unique DisplayMenu instance.
|
// The unique DisplayMenu instance.
|
||||||
static DisplayMenu* PDisplayMenu = 0;
|
static DisplayMenu* PDisplayMenu = 0;
|
||||||
|
|
||||||
|
static int SpansplitIndex = 0;
|
||||||
|
|
||||||
static int sBezelCompID;
|
static int sBezelCompID;
|
||||||
|
static int sScreenDistId;
|
||||||
static int sArcRatioID;
|
static int sArcRatioID;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,8 +54,11 @@ void DisplayMenu::onActivate(void *pDisplayMenu)
|
||||||
// Get the DisplayMenu instance.
|
// Get the DisplayMenu instance.
|
||||||
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
||||||
|
|
||||||
// Load settings from XML file.
|
// Load settings from screen.xml file.
|
||||||
pMenu->loadSettings();
|
pMenu->loadSettings();
|
||||||
|
|
||||||
|
// Load some settings from graph.xml
|
||||||
|
pMenu->loadGraphicSettings();
|
||||||
|
|
||||||
// Initialize GUI from loaded values.
|
// Initialize GUI from loaded values.
|
||||||
pMenu->updateControls();
|
pMenu->updateControls();
|
||||||
|
@ -81,25 +88,58 @@ void DisplayMenu::onChangeMonitorType(tComboBoxInfo *pInfo)
|
||||||
pMenu->setMonitorType((EDisplayType)pInfo->nPos);
|
pMenu->setMonitorType((EDisplayType)pInfo->nPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayMenu::onChangeArcRatio(void *pDisplayMenu)
|
void DisplayMenu::onChangeSpansplit(tComboBoxInfo *pInfo)
|
||||||
{
|
{
|
||||||
printf("DisplayMenu::onChangeArcRatio() \n");
|
// Get the DisplayMenu instance from call-back user data.
|
||||||
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
//DisplayMenu* pMenu = static_cast<DisplayMenu*>(pInfo->userData);
|
||||||
//printf("this = %p \n", this);
|
|
||||||
printf("pMenu->getMenuHandle() = %p \n", pMenu->getMenuHandle());
|
|
||||||
printf("PDisplayMenu->getMenuHandle() = %p \n", PDisplayMenu->getMenuHandle());
|
|
||||||
|
|
||||||
char* val = GfuiEditboxGetString(PDisplayMenu->getMenuHandle(), sArcRatioID);
|
SpansplitIndex = pInfo->nPos;
|
||||||
sscanf(val, "%g", &pMenu->_fArcRatio);
|
}
|
||||||
if (PDisplayMenu->_fArcRatio > 2.0f)
|
|
||||||
PDisplayMenu->_fArcRatio = 2.0f;
|
void DisplayMenu::onChangeBezelComp(void *pDisplayMenu)
|
||||||
else if (PDisplayMenu->_fArcRatio < 0.0f)
|
{
|
||||||
PDisplayMenu->_fArcRatio = 0.0f;
|
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
||||||
|
char* val = GfuiEditboxGetString(PDisplayMenu->getMenuHandle(), sBezelCompID);
|
||||||
|
sscanf(val, "%g", &pMenu->_fBezelComp);
|
||||||
|
if (pMenu->_fBezelComp > 150.0f)
|
||||||
|
pMenu->_fBezelComp = 150.0f;
|
||||||
|
else if (pMenu->_fBezelComp < 50.0f)
|
||||||
|
pMenu->_fBezelComp = 50.0f;
|
||||||
|
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "%g", PDisplayMenu->_fArcRatio);
|
sprintf(buf, "%g", pMenu->_fBezelComp);
|
||||||
GfuiEditboxSetString(PDisplayMenu->getMenuHandle(), sArcRatioID, buf);
|
GfuiEditboxSetString(pMenu->getMenuHandle(), sBezelCompID, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayMenu::onChangeScreenDist(void *pDisplayMenu)
|
||||||
|
{
|
||||||
|
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
||||||
|
char* val = GfuiEditboxGetString(PDisplayMenu->getMenuHandle(), sScreenDistId);
|
||||||
|
sscanf(val, "%g", &pMenu->_fScreenDist);
|
||||||
|
if (pMenu->_fScreenDist > 25.0f)
|
||||||
|
pMenu->_fScreenDist = 25.0f;
|
||||||
|
else if (pMenu->_fScreenDist < 0.1f)
|
||||||
|
pMenu->_fScreenDist = 0.1f;
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "%g", pMenu->_fScreenDist);
|
||||||
|
GfuiEditboxSetString(pMenu->getMenuHandle(), sScreenDistId, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayMenu::onChangeArcRatio(void *pDisplayMenu)
|
||||||
|
{
|
||||||
|
DisplayMenu* pMenu = static_cast<DisplayMenu*>(pDisplayMenu);
|
||||||
|
|
||||||
|
char* val = GfuiEditboxGetString(PDisplayMenu->getMenuHandle(), sArcRatioID);
|
||||||
|
sscanf(val, "%g", &pMenu->_fArcRatio);
|
||||||
|
if (PDisplayMenu->_fArcRatio > 2.0f)
|
||||||
|
PDisplayMenu->_fArcRatio = 2.0f;
|
||||||
|
else if (PDisplayMenu->_fArcRatio < 0.0f)
|
||||||
|
PDisplayMenu->_fArcRatio = 0.0f;
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "%g", PDisplayMenu->_fArcRatio);
|
||||||
|
GfuiEditboxSetString(PDisplayMenu->getMenuHandle(), sArcRatioID, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
|
@ -121,8 +161,11 @@ void DisplayMenu::onAccept(void *pDisplayMenu)
|
||||||
// Force current control to loose focus (if one had it) and update associated variable.
|
// Force current control to loose focus (if one had it) and update associated variable.
|
||||||
GfuiUnSelectCurrent();
|
GfuiUnSelectCurrent();
|
||||||
|
|
||||||
// Save display settings.
|
// Save some settings to screen.xml
|
||||||
pMenu->storeSettings();
|
pMenu->storeSettings();
|
||||||
|
|
||||||
|
// Save some settings to graph.xml
|
||||||
|
pMenu->storeGraphicSettings();
|
||||||
|
|
||||||
// Shutdown the user interface.
|
// Shutdown the user interface.
|
||||||
LegacyMenu::self().shutdown();
|
LegacyMenu::self().shutdown();
|
||||||
|
@ -142,11 +185,28 @@ void DisplayMenu::onCancel(void *pDisplayMenu)
|
||||||
|
|
||||||
void DisplayMenu::updateControls()
|
void DisplayMenu::updateControls()
|
||||||
{
|
{
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
int nControlId = getDynamicControlId("DisplayModeCombo");
|
int nControlId = getDynamicControlId("DisplayModeCombo");
|
||||||
GfuiComboboxSetSelectedIndex(getMenuHandle(), nControlId, _eDisplayMode);
|
GfuiComboboxSetSelectedIndex(getMenuHandle(), nControlId, _eDisplayMode);
|
||||||
|
|
||||||
resetScreenSizes();
|
resetScreenSizes();
|
||||||
|
|
||||||
|
nControlId = getDynamicControlId("MonitorTypeCombo");
|
||||||
|
GfuiComboboxSetSelectedIndex(getMenuHandle(), nControlId, _eDisplayType);
|
||||||
|
|
||||||
|
nControlId = getDynamicControlId("SpanSplitsCombo");
|
||||||
|
GfuiComboboxSetSelectedIndex(getMenuHandle(), nControlId, SpansplitIndex);
|
||||||
|
|
||||||
|
sprintf(buf, "%g", PDisplayMenu->_fBezelComp);
|
||||||
|
GfuiEditboxSetString(getMenuHandle(), sBezelCompID, buf);
|
||||||
|
|
||||||
|
sprintf(buf, "%g", PDisplayMenu->_fScreenDist);
|
||||||
|
GfuiEditboxSetString(getMenuHandle(), sScreenDistId, buf);
|
||||||
|
|
||||||
|
sprintf(buf, "%g", PDisplayMenu->_fArcRatio);
|
||||||
|
GfuiEditboxSetString(getMenuHandle(), sArcRatioID, buf);
|
||||||
|
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
nControlId = getDynamicControlId("MaxRefreshRateCombo");
|
nControlId = getDynamicControlId("MaxRefreshRateCombo");
|
||||||
int nMaxRefRateIndex = 0; // Defaults to None.
|
int nMaxRefRateIndex = 0; // Defaults to None.
|
||||||
|
@ -218,6 +278,93 @@ void DisplayMenu::storeSettings() const
|
||||||
GfParmReleaseHandle(hScrConfParams);
|
GfParmReleaseHandle(hScrConfParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayMenu::loadGraphicSettings()
|
||||||
|
{
|
||||||
|
void* grHandle =
|
||||||
|
GfParmReadFileLocal(GR_PARAM_FILE, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
|
||||||
|
|
||||||
|
// Monitor Type : 4:3, 16:9 or 21:9
|
||||||
|
const char *pszMonitorType =
|
||||||
|
GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_MONITOR, GR_VAL_MONITOR_NONE);
|
||||||
|
|
||||||
|
for (int i = 0; i < nDisplayTypes; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp(pszMonitorType, MonitorTypes[i]))
|
||||||
|
{
|
||||||
|
_eDisplayType = (EDisplayType)i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Span Split Screens
|
||||||
|
const char *pszSpanSplit =
|
||||||
|
GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_SPANSPLIT, GR_VAL_NO);
|
||||||
|
|
||||||
|
SpansplitIndex = 0;
|
||||||
|
for (int i = 0; i < NbSpansplitValues; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp(pszSpanSplit, SpansplitValues[i]))
|
||||||
|
{
|
||||||
|
SpansplitIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bezel Compensation
|
||||||
|
_fBezelComp = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_BEZELCOMP, "%", 110.0f);
|
||||||
|
if (_fBezelComp > 150.0f) {
|
||||||
|
_fBezelComp = 150.0f;
|
||||||
|
}
|
||||||
|
else if (_fBezelComp < 50.0f) {
|
||||||
|
_fBezelComp = 50.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fScreenDist = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SCREENDIST, NULL, 1.0f);
|
||||||
|
if (_fScreenDist > 5.0f)
|
||||||
|
{
|
||||||
|
_fScreenDist = 5.0f;
|
||||||
|
}
|
||||||
|
else if (_fScreenDist < 0.0f)
|
||||||
|
{
|
||||||
|
_fScreenDist = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fArcRatio = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_ARCRATIO, NULL, 1.0f);
|
||||||
|
if (_fArcRatio > 2.0f)
|
||||||
|
{
|
||||||
|
_fArcRatio = 2.0f;
|
||||||
|
}
|
||||||
|
else if (_fArcRatio < 0.0f)
|
||||||
|
{
|
||||||
|
_fArcRatio = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sprintf(buf, "%g", _fArcRatio);
|
||||||
|
//GfuiEditboxSetString(PDisplayMenu->getMenuHandle(), sArcRatioID, buf);
|
||||||
|
//GfuiEditboxSetString(ScrHandle, ArcRatioId, buf);
|
||||||
|
|
||||||
|
// Release screen config params file.
|
||||||
|
GfParmReleaseHandle(grHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save graphical settings to XML file.
|
||||||
|
void DisplayMenu::storeGraphicSettings() const
|
||||||
|
{
|
||||||
|
// Open screen config params file.
|
||||||
|
void* grHandle = GfParmReadFileLocal(GR_PARAM_FILE, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
|
||||||
|
|
||||||
|
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_MONITOR, MonitorTypes[_eDisplayType]);
|
||||||
|
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_SPANSPLIT, SpansplitValues[SpansplitIndex]);
|
||||||
|
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_BEZELCOMP, "%", _fBezelComp);
|
||||||
|
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SCREENDIST, NULL, _fScreenDist);
|
||||||
|
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_ARCRATIO, NULL, _fArcRatio);
|
||||||
|
|
||||||
|
GfParmWriteFile(NULL, grHandle, "graph");
|
||||||
|
|
||||||
|
GfParmReleaseHandle(grHandle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayMenu::setDisplayMode(EDisplayMode eMode)
|
void DisplayMenu::setDisplayMode(EDisplayMode eMode)
|
||||||
{
|
{
|
||||||
if (_eDisplayMode != eMode)
|
if (_eDisplayMode != eMode)
|
||||||
|
@ -374,10 +521,10 @@ bool DisplayMenu::initialize(void *pPreviousMenu)
|
||||||
createComboboxControl("MonitorTypeCombo", this, onChangeMonitorType);
|
createComboboxControl("MonitorTypeCombo", this, onChangeMonitorType);
|
||||||
|
|
||||||
const int nSpanSplitsComboId =
|
const int nSpanSplitsComboId =
|
||||||
createComboboxControl("SpanSplitsCombo", this, NULL);
|
createComboboxControl("SpanSplitsCombo", this, onChangeSpansplit);
|
||||||
|
|
||||||
sBezelCompID = createEditControl("bezelcompedit", this, NULL, NULL);
|
sBezelCompID = createEditControl("bezelcompedit", this, NULL, onChangeBezelComp);
|
||||||
createEditControl("screendistedit", this, NULL, NULL);
|
sScreenDistId = createEditControl("screendistedit", this, NULL, onChangeScreenDist);
|
||||||
sArcRatioID = createEditControl("arcratioedit", this, NULL, onChangeArcRatio);
|
sArcRatioID = createEditControl("arcratioedit", this, NULL, onChangeArcRatio);
|
||||||
|
|
||||||
|
|
||||||
|
@ -410,7 +557,7 @@ bool DisplayMenu::initialize(void *pPreviousMenu)
|
||||||
for (int nDisplayTypeInd = 0; nDisplayTypeInd < nDisplayTypes; nDisplayTypeInd++)
|
for (int nDisplayTypeInd = 0; nDisplayTypeInd < nDisplayTypes; nDisplayTypeInd++)
|
||||||
GfuiComboboxAddText(getMenuHandle(), nDisplayTypeComboId, MonitorTypes[nDisplayTypeInd]);
|
GfuiComboboxAddText(getMenuHandle(), nDisplayTypeComboId, MonitorTypes[nDisplayTypeInd]);
|
||||||
|
|
||||||
for (int index = 0; index < 2; index++)
|
for (int index = 0; index < NbSpansplitValues; index++)
|
||||||
GfuiComboboxAddText(getMenuHandle(), nSpanSplitsComboId, SpansplitValues[index]);
|
GfuiComboboxAddText(getMenuHandle(), nSpanSplitsComboId, SpansplitValues[index]);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ public:
|
||||||
void storeSettings() const;
|
void storeSettings() const;
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
|
void storeGraphicSettings() const;
|
||||||
|
void loadGraphicSettings();
|
||||||
|
|
||||||
void updateControls();
|
void updateControls();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -64,6 +67,9 @@ protected:
|
||||||
static void onChangeScreenSize(tComboBoxInfo *pInfo);
|
static void onChangeScreenSize(tComboBoxInfo *pInfo);
|
||||||
static void onChangeDisplayMode(tComboBoxInfo *pInfo);
|
static void onChangeDisplayMode(tComboBoxInfo *pInfo);
|
||||||
static void onChangeMonitorType(tComboBoxInfo *pInfo);
|
static void onChangeMonitorType(tComboBoxInfo *pInfo);
|
||||||
|
static void onChangeSpansplit(tComboBoxInfo *pInfo);
|
||||||
|
static void onChangeBezelComp(void *pDisplayMenu);
|
||||||
|
static void onChangeScreenDist(void *pDisplayMenu);
|
||||||
static void onChangeArcRatio(void *pDisplayMenu);
|
static void onChangeArcRatio(void *pDisplayMenu);
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
static void onChangeMaxRefreshRate(tComboBoxInfo *pInfo);
|
static void onChangeMaxRefreshRate(tComboBoxInfo *pInfo);
|
||||||
|
|
Loading…
Reference in a new issue