3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
26 stringoption
ivanconfig::DefaultName("DefaultName", "player's default name", "", &configsystem::NormalStringDisplayer
, &DefaultNameChangeInterface
);
27 stringoption
ivanconfig::DefaultPetName("DefaultPetName", "starting pet's default name", CONST_S("Kenny"), &configsystem::NormalStringDisplayer
, &DefaultPetNameChangeInterface
);
28 numberoption
ivanconfig::AutoSaveInterval("AutoSaveInterval", "autosave interval", 100, &AutoSaveIntervalDisplayer
, &AutoSaveIntervalChangeInterface
, &AutoSaveIntervalChanger
);
29 scrollbaroption
ivanconfig::Contrast("Contrast", "contrast", 100, &ContrastDisplayer
, &ContrastChangeInterface
, &ContrastChanger
, &ContrastHandler
);
30 truthoption
ivanconfig::WarnAboutDanger("WarnAboutVeryDangerousMonsters", "Warn about very dangerous monsters", true);
31 truthoption
ivanconfig::AutoDropLeftOvers("AutoDropLeftOvers", "drop food leftovers automatically", true);
32 truthoption
ivanconfig::AutoDropBottles("AutoDropBottles", "automatically drop empty bottles after drinking", true);
33 truthoption
ivanconfig::AutoDropCans("AutoDropCans", "automatically drop empty cans after eating/drinking", false);
34 truthoption
ivanconfig::LookZoom("LookZoom", "zoom feature in look mode", false);
35 truthoption
ivanconfig::UseAlternativeKeys("UseAlternativeKeys", "use alternative direction keys", false);
36 truthoption
ivanconfig::BeNice("BeNice", "be nice to pets", true);
37 truthoption
ivanconfig::FullScreenMode("FullScreenMode", "run the game in full screen mode", false, &configsystem::NormalTruthDisplayer
, &configsystem::NormalTruthChangeInterface
, &FullScreenModeChanger
);
39 truthoption
ivanconfig::DoubleResMode("DoubleResMode", "run the game in double-resolution mode", false);
40 truthoption
ivanconfig::KickDownDoors("KickDownDoors", "kick down doors by default", false);
41 truthoption
ivanconfig::AutoCenterMap("AutoCenterMap", "automatically center map when player moves", true);
42 truthoption
ivanconfig::AutoCenterMapOnLook("AutoCenterMapOnLook", "automatically center map when player looks", true);
43 truthoption
ivanconfig::FastListMode("FastLists", "instantly select list items with alpha keys", true, &configsystem::NormalTruthDisplayer
, &configsystem::NormalTruthChangeInterface
, &FastListChanger
);
44 truthoption
ivanconfig::PlaySounds("PlaySounds", "use sounds", false);
45 scrollbaroption
ivanconfig::SoundVolume("SoundVolume", "sound volume", 128, &SoundVolumeDisplayer
, &SoundVolumeChangeInterface
, &ContrastChanger
, &SoundVolumeHandler
);
46 truthoption
ivanconfig::ConfirmCorpses("ConfirmCorpses", "confirm corpse pickup", true);
47 truthoption
ivanconfig::StopOnCorpses("StopOnCorpses", "abort going on corpses", false);
48 truthoption
ivanconfig::StopOnSeenItems("StopOnSeenItems", "abort going on seen items", false);
49 truthoption
ivanconfig::StopOnSeenDoors("StopOnSeenDoors", "abort going on seen doors", false);
50 truthoption
ivanconfig::ConfirmScrollReading("ConfirmScrollReading", "confirm scroll reading", false);
51 numberoption
ivanconfig::GoingDelay("GoingDelay", "delay betwen steps in 'go' command", 100, &GoingDelayDisplayer
, &GoingDelayChangeInterface
, &GoingDelayChanger
);
52 truthoption
ivanconfig::UseMaximumCompression("UseMaximumCompression", "use maximum compression", false);
53 truthoption
ivanconfig::ShowFullItemDesc("ShowFullItemDesc", "show detailed description of lying item", false);
56 void ivanconfig::SoundVolumeDisplayer (const numberoption
*O
, festring
&Entry
) {
57 Entry
<< O
->Value
<< "/128";
61 truth
ivanconfig::SoundVolumeChangeInterface (numberoption
*O
) {
62 iosystem::ScrollBarQuestion(CONST_S("Set new sound volume (0-128, '<' and '>' move the slider):"),
63 GetQuestionPos(), O
->Value
, 16, 0, 128, O
->Value
, WHITE
, LIGHT_GRAY
, DARK_GRAY
, game::GetMoveCommandKey(KEY_LEFT_INDEX
), game::GetMoveCommandKey(KEY_RIGHT_INDEX
), !game::IsRunning(), static_cast<scrollbaroption
*>(O
)->BarHandler
);
64 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
69 void ivanconfig::SoundVolumeChanger (numberoption
*O
, sLong What
) {
70 if (What
< 0) What
= 0;
71 if (What
> 128) What
= 128;
73 soundsystem::setVolume(What
);
77 void ivanconfig::SoundVolumeHandler (sLong Value
) {
78 SoundVolumeChanger(&SoundVolume
, Value
);
83 col24
ivanconfig::ContrastLuminance
= NORMAL_LUMINANCE
;
84 v2
ivanconfig::GetQuestionPos () { return game::IsRunning() ? v2(16, 6) : v2(30, 30); }
85 void ivanconfig::BackGroundDrawer () { game::DrawEverythingNoBlit(); }
88 void ivanconfig::AutoSaveIntervalDisplayer (const numberoption
*O
, festring
&Entry
) {
90 Entry
<< O
->Value
<< " turn";
91 if (O
->Value
!= 1) Entry
<< 's';
98 void ivanconfig::ContrastDisplayer (const numberoption
*O
, festring
&Entry
) {
99 Entry
<< O
->Value
<< "/100";
103 truth
ivanconfig::DefaultNameChangeInterface (stringoption
*O
) {
105 if (iosystem::StringQuestion(String
, CONST_S("Set new default name (1-20 letters):"), GetQuestionPos(), WHITE
, 0, 20, !game::IsRunning(), true) == NORMAL_EXIT
)
106 O
->ChangeValue(String
);
107 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
112 truth
ivanconfig::DefaultPetNameChangeInterface (stringoption
*O
) {
114 if (iosystem::StringQuestion(String
, CONST_S("Set new default name for the starting pet (1-20 letters):"), GetQuestionPos(), WHITE
, 0, 20, !game::IsRunning(), true) == NORMAL_EXIT
)
115 O
->ChangeValue(String
);
116 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
121 truth
ivanconfig::AutoSaveIntervalChangeInterface (numberoption
*O
) {
122 O
->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new autosave interval (1-50000 turns, 0 for never):"), GetQuestionPos(), WHITE
, !game::IsRunning()));
123 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
128 truth
ivanconfig::ContrastChangeInterface (numberoption
*O
) {
129 iosystem::ScrollBarQuestion(CONST_S("Set new contrast value (0-200, '<' and '>' move the slider):"), GetQuestionPos(), O
->Value
, 5, 0, 200, O
->Value
, WHITE
, LIGHT_GRAY
, DARK_GRAY
, game::GetMoveCommandKey(KEY_LEFT_INDEX
), game::GetMoveCommandKey(KEY_RIGHT_INDEX
), !game::IsRunning(), static_cast<scrollbaroption
*>(O
)->BarHandler
);
130 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
135 void ivanconfig::AutoSaveIntervalChanger (numberoption
*O
, sLong What
) {
136 if (What
< 0) What
= 0;
137 if (What
> 50000) What
= 50000;
142 void ivanconfig::ContrastChanger (numberoption
*O
, sLong What
) {
143 if (What
< 0) What
= 0;
144 if (What
> 200) What
= 200;
146 CalculateContrastLuminance();
150 void ivanconfig::FullScreenModeChanger (truthoption
*, truth
) {
151 graphics::SwitchMode();
155 void ivanconfig::FastListChanger (truthoption
*O
, truth value
) {
156 //fprintf(stderr, "FLC: %s\n", value ? "TAN" : "ona");
157 FastListMode
.Value
= !FastListMode
.Value
;
158 felist::SetFastListMode(!FastListMode
.Value
);
162 void ivanconfig::Show () {
163 configsystem::Show(&BackGroundDrawer
, &game::SetStandardListAttributes
, game::IsRunning());
167 void ivanconfig::ContrastHandler (sLong Value
) {
168 ContrastChanger(&Contrast
, Value
);
169 if (game::IsRunning()) {
170 game::GetCurrentArea()->SendNewDrawRequest();
171 game::DrawEverythingNoBlit();
176 void ivanconfig::SwitchModeHandler () {
177 FullScreenMode
.Value
= !FullScreenMode
.Value
;
182 void ivanconfig::CalculateContrastLuminance () {
183 int Element
= Min
<sLong
>((GetContrast() << 7) / 100, 255);
184 ContrastLuminance
= MakeRGB24(Element
, Element
, Element
);
188 void ivanconfig::GoingDelayDisplayer (const numberoption
*O
, festring
&Entry
) {
190 Entry
<< O
->Value
<< " ms";
197 truth
ivanconfig::GoingDelayChangeInterface (numberoption
*O
) {
198 O
->ChangeValue(iosystem::NumberQuestion(CONST_S("Set new 'go' delay (0-2000):"), GetQuestionPos(), WHITE
, !game::IsRunning()));
199 if (game::IsRunning()) igraph::BlitBackGround(v2(16, 6), v2(game::GetScreenXSize() << 4, 23));
204 void ivanconfig::GoingDelayChanger (numberoption
*O
, sLong What
) {
205 if (What
< 0) What
= 0;
206 if (What
> 2000) What
= 2000;
211 festring
ivanconfig::GetMyDir (void) { return inputfile::GetMyDir(); }
214 static festring
getConfigPath () {
217 path
<< ivanconfig::GetMyDir();
219 path
<< getenv("HOME");
225 void ivanconfig::Initialize () {
226 configsystem::AddOption(&DefaultName
);
227 configsystem::AddOption(&DefaultPetName
);
228 configsystem::AddOption(&AutoSaveInterval
);
229 configsystem::AddOption(&Contrast
);
230 configsystem::AddOption(&WarnAboutDanger
);
231 configsystem::AddOption(&AutoDropLeftOvers
);
232 configsystem::AddOption(&AutoDropBottles
);
233 configsystem::AddOption(&AutoDropCans
);
234 configsystem::AddOption(&LookZoom
);
235 configsystem::AddOption(&UseAlternativeKeys
);
236 configsystem::AddOption(&BeNice
);
237 configsystem::AddOption(&FullScreenMode
);
239 configsystem::AddOption(&DoubleResMode
);
240 configsystem::AddOption(&KickDownDoors
);
241 configsystem::AddOption(&AutoCenterMap
);
242 configsystem::AddOption(&AutoCenterMapOnLook
);
243 configsystem::AddOption(&FastListMode
);
244 configsystem::AddOption(&PlaySounds
);
245 configsystem::AddOption(&SoundVolume
);
246 configsystem::AddOption(&ConfirmCorpses
);
247 configsystem::AddOption(&StopOnCorpses
);
248 configsystem::AddOption(&StopOnSeenItems
);
249 configsystem::AddOption(&StopOnSeenDoors
);
250 configsystem::AddOption(&ConfirmScrollReading
);
251 configsystem::AddOption(&GoingDelay
);
252 configsystem::AddOption(&UseMaximumCompression
);
253 configsystem::AddOption(&ShowFullItemDesc
);
255 configsystem::SetConfigFileName(getConfigPath()+"/.ivan.rc");
256 configsystem::Load();
257 felist::SetFastListMode(!FastListMode
.Value
);
258 CalculateContrastLuminance();
260 commandsystem::ConfigureKeys();
261 commandsystem::SaveKeys(false);