mirror of
https://github.com/spiffcode/hostile-takeover.git
synced 2026-04-12 22:41:27 -06:00
Add max FPS to game options
This commit is contained in:
parent
7932f4cc00
commit
05f1755637
@ -76,12 +76,15 @@
|
||||
[kidfInGameOptions]
|
||||
FORM=(0 0 160 160) kidcCancel center
|
||||
LABEL=0 (38 6 83 0) "GAME OPTIONS" kifntTitle center
|
||||
LABEL=0 (11 26 68 0) "Game Speed" kifntShadow
|
||||
SLIDER=kidcGameSpeed (11 40 95 8)
|
||||
LABEL=kidcGameSpeedLabel (121 40 17 0) "0" kifntShadow right
|
||||
LABEL=0 (11 56 68 0) "Scroll Speed" kifntShadow
|
||||
SLIDER=kidcScrollSpeed (11 70 95 8)
|
||||
LABEL=kidcScrollSpeedLabel (121 70 17 0) "0" kifntShadow right
|
||||
LABEL=0 (11 22 68 0) "Game Speed" kifntShadow
|
||||
SLIDER=kidcGameSpeed (11 32 95 8)
|
||||
LABEL=kidcGameSpeedLabel (121 32 17 0) "0" kifntShadow right
|
||||
LABEL=0 (11 44 68 0) "Scroll Speed" kifntShadow
|
||||
SLIDER=kidcScrollSpeed (11 54 95 8)
|
||||
LABEL=kidcScrollSpeedLabel (121 54 17 0) "0" kifntShadow right
|
||||
LABEL=0 (11 66 68 0) "Max FPS" kifntShadow
|
||||
SLIDER=kidcMaxFPS (11 76 95 8)
|
||||
LABEL=kidcMaxFPSLabel (121 76 17 0) "0" kifntShadow right
|
||||
LABEL=0 (11 89 68 0) "Difficulty" kifntShadow
|
||||
CHECKBOX=kidcEasy (11 99 67 0) "Easy" kifntShadow
|
||||
CHECKBOX=kidcNormal (11 109 67 0) "Normal" kifntShadow
|
||||
|
||||
@ -36,6 +36,21 @@ bool gfStylusUI = false;
|
||||
#define SetControlChecked(id, f) ((CheckBoxControl *)GetControlPtr(id))->SetChecked(f)
|
||||
#define GetControlChecked(id) ((CheckBoxControl *)GetControlPtr(id))->IsChecked()
|
||||
|
||||
// Mimimum ms options to elapse between paints
|
||||
|
||||
int gacmsFPSOptions[10] = {
|
||||
50, // 20 FPS
|
||||
33, // 30 FPS
|
||||
25, // 40 FPS
|
||||
20, // 50 FPS
|
||||
16, // 62 FPS
|
||||
14, // 71 FPS
|
||||
12, // 83 FPS
|
||||
11, // 90 FPS
|
||||
10, // 100 FPS
|
||||
8 // 125 FPS
|
||||
};
|
||||
|
||||
// GameOptions
|
||||
|
||||
class GameOptionsForm : public ShellForm
|
||||
@ -332,6 +347,7 @@ bool InGameOptionsForm::Init(FormMgr *pfrmm, IniReader *pini, word idf)
|
||||
m_tGameSpeed = gtGameSpeed;
|
||||
m_wfHandicap = gwfHandicap;
|
||||
m_nScrollSpeed = gnScrollSpeed;
|
||||
m_cmsMaxFPS = gcmsDisplayUpdate;
|
||||
|
||||
#if defined(IPHONE) || defined(__IPHONEOS__) || defined(__ANDROID__)
|
||||
GetControlPtr(kidcLassoSelection)->Show(false);
|
||||
@ -384,6 +400,18 @@ void InGameOptionsForm::InitResettableControls()
|
||||
psldr->SetRange(0, (knScrollSpeedMax - 1) * 4);
|
||||
psldr->SetValue((m_nScrollSpeed - 1.0) / 0.25);
|
||||
|
||||
// Max FPS
|
||||
|
||||
psldr = (SliderControl *)GetControlPtr(kidcMaxFPS);
|
||||
psldr->SetRange(0, ARRAYSIZE(gacmsFPSOptions) - 1);
|
||||
psldr->SetValue(0);
|
||||
for (int i = 0; i < ARRAYSIZE(gacmsFPSOptions); i++) {
|
||||
if (gacmsFPSOptions[i] == m_cmsMaxFPS) {
|
||||
psldr->SetValue(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Difficulty
|
||||
|
||||
SetControlChecked(kidcEasy, m_wfHandicap == kfHcapEasy);
|
||||
@ -405,6 +433,10 @@ void InGameOptionsForm::UpdateLabels()
|
||||
int cFrac = (m_nScrollSpeed - (int)m_nScrollSpeed) * 100;
|
||||
sprintf(szT, "%d.%dx", cWhole, cFrac);
|
||||
plbl->SetText(szT);
|
||||
|
||||
plbl = (LabelControl *)GetControlPtr(kidcMaxFPSLabel);
|
||||
sprintf(szT, "%.1f", (float)1000 / (float)m_cmsMaxFPS);
|
||||
plbl->SetText(szT);
|
||||
}
|
||||
|
||||
void InGameOptionsForm::OnControlSelected(word idc)
|
||||
@ -434,6 +466,15 @@ void InGameOptionsForm::OnControlSelected(word idc)
|
||||
}
|
||||
break;
|
||||
|
||||
case kidcMaxFPS:
|
||||
{
|
||||
SliderControl *psldr =
|
||||
(SliderControl *)GetControlPtr(kidcMaxFPS);
|
||||
m_cmsMaxFPS = gacmsFPSOptions[psldr->GetValue()];
|
||||
UpdateLabels();
|
||||
}
|
||||
break;
|
||||
|
||||
case kidcEasy:
|
||||
case kidcNormal:
|
||||
case kidcHard:
|
||||
@ -460,6 +501,8 @@ void InGameOptionsForm::OnControlSelected(word idc)
|
||||
ggame.SetGameSpeed(gatGameSpeeds[psldr->GetValue()]);
|
||||
psldr = (SliderControl *)GetControlPtr(kidcScrollSpeed);
|
||||
gnScrollSpeed = 1.0 + psldr->GetValue() * 0.25;
|
||||
psldr = (SliderControl *)GetControlPtr(kidcMaxFPS);
|
||||
gcmsDisplayUpdate = gacmsFPSOptions[psldr->GetValue()];
|
||||
|
||||
// Difficulty
|
||||
|
||||
@ -490,6 +533,7 @@ void InGameOptionsForm::OnControlSelected(word idc)
|
||||
m_tGameSpeed = kcmsUpdate / 20;
|
||||
m_nScrollSpeed = 1.0;
|
||||
m_wfHandicap = kfHcapDefault;
|
||||
m_cmsMaxFPS = 8; // 125 FPS
|
||||
InitResettableControls();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -296,6 +296,7 @@ bool Game::Init(int imm)
|
||||
// gfIgnoreBluetoothWarning = gpprefs->GetBool(kfPrefIgnoreBluetoothWarning);
|
||||
strncpy(gszAskURL, gpprefs->GetString(kszPrefAskUrl), sizeof(gszAskURL));
|
||||
strncpy(gszDeviceId, gpprefs->GetString(kszPrefDeviceId), sizeof(gszDeviceId));
|
||||
gcmsDisplayUpdate = gpprefs->GetInteger(knPrefUpdateDisplay);
|
||||
|
||||
// Temp buffer used for several things, including decompression, TBitmap compiling.
|
||||
|
||||
@ -2522,6 +2523,7 @@ void Game::SavePreferences()
|
||||
}
|
||||
|
||||
gpprefs->Set(kszPrefKey, (const char *)gkey.ab);
|
||||
gpprefs->Set(knPrefUpdateDisplay, gcmsDisplayUpdate);
|
||||
|
||||
#if defined(WIN) && !defined(CE)
|
||||
if (gpdisp == NULL) {
|
||||
|
||||
@ -2842,6 +2842,7 @@ private:
|
||||
long m_tGameSpeed;
|
||||
word m_wfHandicap;
|
||||
double m_nScrollSpeed;
|
||||
int m_cmsMaxFPS;
|
||||
};
|
||||
|
||||
// Control
|
||||
@ -8357,6 +8358,7 @@ bool DrmValidate() secDrm;
|
||||
// #define kfPrefIgnoreBluetoothWarning "ignore_bluetooth_warning"
|
||||
#define kszPrefAskUrl "ask_url"
|
||||
#define kszPrefDeviceId "did"
|
||||
#define knPrefUpdateDisplay "update_display"
|
||||
|
||||
class Preferences
|
||||
{
|
||||
|
||||
@ -99,6 +99,7 @@ bool Preferences::InitFromDeafults() {
|
||||
Set(knPrefScrollSpeed, 1.0f);
|
||||
Set(kszPrefAskUrl, "http://");
|
||||
Set(kszPrefDeviceId, HostGenerateDeviceId());
|
||||
Set(knPrefUpdateDisplay, 8); // 125 FPS
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -429,6 +429,8 @@
|
||||
#define kidc1Select2Scroll 1203
|
||||
#define kidcScrollSpeed 1204
|
||||
#define kidcScrollSpeedLabel 1205
|
||||
#define kidcMaxFPS 1206
|
||||
#define kidcMaxFPSLabel 1207
|
||||
|
||||
// SoundOptions constants
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user