• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


Commit MetaInfo

Revision272 (tree)
Time2021-03-23 23:45:32
Authorxops-mikan

Log Message

datファイルとiniファイルによるゲーム設定読み込み関数を分離

Change Summary

Incremental Difference

--- trunk/config.cpp (revision 271)
+++ trunk/config.cpp (revision 272)
@@ -58,9 +58,8 @@
5858
5959 //! @brief 設定ファイルを読み込む
6060 //! @param fname ファイル名
61-//! @param fname ファイル名2(.ini)
6261 //! @return 成功:0 失敗:1
63-int Config::LoadFile(char *fname, char *fname2)
62+int Config::LoadFile(char *fname)
6463 {
6564 FILE *fp;
6665 char buf;
@@ -135,47 +134,6 @@
135134 //ログに出力
136135 OutputLog.WriteLog(LOG_COMPLETE, "", "");
137136 #endif
138-
139-
140-#ifdef ENABLE_ADDCONFIG
141- INIFileInterface INIConfig;
142- int mode;
143-
144-#ifdef ENABLE_DEBUGLOG
145- //ログに出力
146- OutputLog.WriteLog(LOG_LOAD, "設定ファイル(.ini)", fname2);
147-#endif
148-
149- INIConfig.LoadINIFile(fname2);
150-
151- //解像度取得
152- mode = INIConfig.GetINIFileInt("Graphics", "WindowSize", -1, NULL);
153- switch(mode){
154- case 0: ScreenWidth = 640; ScreenHeight = 480; break;
155- case 1: ScreenWidth = 800; ScreenHeight = 600; break;
156- case 2: ScreenWidth = 1024; ScreenHeight = 768; break;
157- case 3: ScreenWidth = 1280; ScreenHeight = 960; break;
158- case 4: ScreenWidth = 1600; ScreenHeight = 1200; break;
159- case 10: ScreenWidth = 1280; ScreenHeight = 720; break;
160- case 11: ScreenWidth = 1600; ScreenHeight = 900; break;
161- case 12: ScreenWidth = 1920; ScreenHeight = 1080; break;
162- case 13: ScreenWidth = 2560; ScreenHeight = 1440; break;
163- case 14: ScreenWidth = 3840; ScreenHeight = 2160; break;
164- default: ScreenWidth = DEFAULT_SCREEN_WIDTH; ScreenHeight = DEFAULT_SCREEN_HEIGHT; break;
165- }
166-
167- INIConfig.ReleaseINIFile();
168-
169-#ifdef ENABLE_DEBUGLOG
170- //ログに出力
171- OutputLog.WriteLog(LOG_COMPLETE, "", "");
172-#endif
173-
174-#else
175- ScreenWidth = DEFAULT_SCREEN_WIDTH;
176- ScreenHeight = DEFAULT_SCREEN_HEIGHT;
177-#endif
178-
179137 return 0;
180138 }
181139
@@ -290,9 +248,6 @@
290248 FrameskipFlag = false;
291249 AnotherGunsightFlag = false;
292250 strcpy(PlayerName, "xopsplayer");
293-
294- ScreenWidth = DEFAULT_SCREEN_WIDTH;
295- ScreenHeight = DEFAULT_SCREEN_HEIGHT;
296251 }
297252
298253 //! @brief オリジナルキーコードを取得
@@ -550,6 +505,60 @@
550505 return out;
551506 }
552507
508+//! @brief 追加設定ファイルを読み込む
509+//! @param fname ファイル名
510+//! @return 成功:0 失敗:1
511+int Config::LoadExtFile(char *fname)
512+{
513+#ifdef ENABLE_ADDCONFIG
514+ INIFileInterface INIConfig;
515+ int mode;
516+
517+#ifdef ENABLE_DEBUGLOG
518+ //ログに出力
519+ OutputLog.WriteLog(LOG_LOAD, "設定ファイル(.ini)", fname);
520+#endif
521+
522+ INIConfig.LoadINIFile(fname);
523+
524+ //解像度取得
525+ mode = INIConfig.GetINIFileInt("Graphics", "WindowSize", -1, NULL);
526+ switch(mode){
527+ case 0: ScreenWidth = 640; ScreenHeight = 480; break;
528+ case 1: ScreenWidth = 800; ScreenHeight = 600; break;
529+ case 2: ScreenWidth = 1024; ScreenHeight = 768; break;
530+ case 3: ScreenWidth = 1280; ScreenHeight = 960; break;
531+ case 4: ScreenWidth = 1600; ScreenHeight = 1200; break;
532+ case 10: ScreenWidth = 1280; ScreenHeight = 720; break;
533+ case 11: ScreenWidth = 1600; ScreenHeight = 900; break;
534+ case 12: ScreenWidth = 1920; ScreenHeight = 1080; break;
535+ case 13: ScreenWidth = 2560; ScreenHeight = 1440; break;
536+ case 14: ScreenWidth = 3840; ScreenHeight = 2160; break;
537+ default: ScreenWidth = DEFAULT_SCREEN_WIDTH; ScreenHeight = DEFAULT_SCREEN_HEIGHT; break;
538+ }
539+
540+ INIConfig.ReleaseINIFile();
541+
542+#ifdef ENABLE_DEBUGLOG
543+ //ログに出力
544+ OutputLog.WriteLog(LOG_COMPLETE, "", "");
545+#endif
546+
547+#else
548+ ScreenWidth = DEFAULT_SCREEN_WIDTH;
549+ ScreenHeight = DEFAULT_SCREEN_HEIGHT;
550+#endif
551+ return 0;
552+}
553+
554+
555+//! @brief 追加設定値をデフォルトの値で初期化
556+void Config::SetDefaultExtConfig()
557+{
558+ ScreenWidth = DEFAULT_SCREEN_WIDTH;
559+ ScreenHeight = DEFAULT_SCREEN_HEIGHT;
560+}
561+
553562 //! @brief 画面解像度(幅)を取得
554563 //! @return 値
555564 int Config::GetScreenWidth()
--- trunk/config.h (revision 271)
+++ trunk/config.h (revision 272)
@@ -84,7 +84,7 @@
8484 public:
8585 Config();
8686 ~Config();
87- int LoadFile(char *fname, char *fname2);
87+ int LoadFile(char *fname);
8888 int SaveFile(char *fname);
8989 void SetDefaultConfig();
9090 int GetKeycode(int id);
@@ -109,6 +109,8 @@
109109 void SetPlayerName(char *in_str);
110110 char* GetOriginalkeycodeString(int code);
111111
112+ int LoadExtFile(char *fname);
113+ void SetDefaultExtConfig();
112114 int GetScreenWidth();
113115 int GetScreenHeight();
114116 };
--- trunk/gamemain.cpp (revision 271)
+++ trunk/gamemain.cpp (revision 272)
@@ -1245,7 +1245,7 @@
12451245 //Cancel
12461246 if( Options_p2LinkTextID == 2 ){
12471247 //設定ファイル読み直す
1248- if( GameConfig.LoadFile("config.dat", "config-openxops.ini") == 1 ){
1248+ if( GameConfig.LoadFile("config.dat") == 1 ){
12491249 //MainWindow.ErrorInfo("config data open failed");
12501250 //return 1;
12511251 }
--- trunk/main.cpp (revision 271)
+++ trunk/main.cpp (revision 272)
@@ -169,7 +169,7 @@
169169 #endif
170170
171171 //設定ファイル読み込み
172- if( GameConfig.LoadFile("config.dat", "config-openxops.ini") == 1 ){
172+ if( GameConfig.LoadFile("config.dat") == 1 ){
173173 #ifndef ENABLE_AUTOCREATECONFIG
174174 MainWindow.ErrorInfo("config data open failed");
175175 return 1;
@@ -183,6 +183,13 @@
183183 #endif
184184 }
185185
186+ //追加設定を読み込む
187+#ifdef ENABLE_ADDCONFIG
188+ GameConfig.LoadExtFile("config-openxops.ini");
189+#else
190+ GameConfig.LoadExtFile(NULL);
191+#endif
192+
186193 #ifdef ENABLE_DEBUGLOG
187194 //ログに出力
188195 sprintf(infostr, "解像度:%d x %d", GameConfig.GetScreenWidth(), GameConfig.GetScreenHeight());