Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CSimulationMode.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Sun Aug 15 01:53:13 2010 UTC (13 years, 9 months ago) by okadu
File MIME type: text/x-c++src
File size: 5168 byte(s)


1 #include "stdafx.h"
2 #include "CSkinPlugin.h"
3 #include "CSimulationMode.h"
4
5 // 内部定数
6 const int WW = 512, WH = 384; // 窓サイズ
7 const int TIME_SCALE_MAX = 10;
8
9 // 内部グローバル
10 bool g_ManualControl = false;
11 bool g_IgnoreAcceleration = false;
12
13 const int SCALE_TABLE[TIME_SCALE_NUM] = {
14 2880, 1400, 480, 288, 144, 72, 48, 24, 6, 1}; // 実世界 1 秒あたりゲーム内秒数
15 const int SPEED_TABLE[SIM_SPEED_NUM] = {
16 0, 1, 2, 10, 100}; // シミュレーション倍速
17
18 /*
19 * ゲーム内 1 日あたりフレーム数
20 * 900, 1800, 5400, 9000, 18000, 36000, 54000, 108000, 432000, 2592000
21 */
22
23 /*
24 * コンストラクタ
25 */
26 CSimulationMode::CSimulationMode(){
27 int i, wide = WW-TILE_UNIT*2, win = wide-TILE_UNIT*2;
28 m_SimulationWindow.Init((g_DispWidth-WW)/2-TILE_UNIT, (g_DispHeight-WH)/2,
29 WW, WH, lang(SimulationSetting), &m_Interface, true);
30 m_ScaleGroup.Init(TILE_UNIT, TILE_UNIT*2, wide, TILE_UNIT*4,
31 lang(TimeScale_Exp), &m_SimulationWindow);
32 string dlstr[TIME_SCALE_MAX] = {
33 FlashIn("30 %s", lang(Sec)), FlashIn("1 %s", lang(Min)),
34 FlashIn("3 %s", lang(Min)), FlashIn("5 %s (%s)", lang(Min), lang(Init)),
35 FlashIn("10 %s", lang(Min)), FlashIn("20 %s", lang(Min)),
36 FlashIn("30 %s", lang(Min)), FlashIn("1 %s", lang(Hour)),
37 FlashIn("4 %s", lang(Hour)), FlashIn("24 %s", lang(Hour))
38 };
39 for(i = 0; i<5; i++) m_TimeScale[i].Init(
40 TILE_UNIT+win*i/5, TILE_UNIT+TILE_QUAD,
41 win*(i+1)/5-win*i/5-TILE_HALF, TILE_UNIT,
42 (char *)dlstr[i].c_str(), &m_ScaleGroup, i ? &m_TimeScale[i-1] : NULL);
43 for(i = 5; i<TIME_SCALE_MAX; i++) m_TimeScale[i].Init(
44 TILE_UNIT+win*(i-5)/5, TILE_UNIT*2+TILE_QUAD,
45 win*(i-4)/5-win*(i-5)/5-TILE_HALF, TILE_UNIT,
46 (char *)dlstr[i].c_str(), &m_ScaleGroup, &m_TimeScale[i-1]);
47 m_SpeedGroup.Init(TILE_UNIT, TILE_UNIT*7,
48 wide, TILE_UNIT*3, lang(SimulationSpeed), &m_SimulationWindow);
49 string ffstr[5] = {
50 lang(Paused), lang(UnitSp),
51 FlashIn("2 %s", lang(XSpeed)),
52 FlashIn("10 %s", lang(XSpeed)),
53 FlashIn("100 %s", lang(XSpeed))
54 };
55 for(i = 0; i<5; i++) m_SimSpeed[i].Init(
56 TILE_UNIT+win*i/5, TILE_UNIT+TILE_QUAD,
57 win*(i+1)/5-win*i/5-TILE_HALF, TILE_UNIT,
58 (char *)ffstr[i].c_str(), &m_SpeedGroup, i ? &m_SimSpeed[i-1] : NULL);
59 m_TimeGroup.Init(TILE_UNIT, TILE_UNIT*11,
60 WW-TILE_UNIT*2, TILE_UNIT*4, lang(TimeProgress), &m_SimulationWindow);
61 m_RotLabel.Init(TILE_UNIT, TILE_UNIT+TILE_QUAD, TILE_UNIT*8, TILE_UNIT,
62 lang(Rotation_Time), &m_TimeGroup, 0, 1);
63 int trw = WW-TILE_UNIT*12;
64 string rotstr[3] = {lang(Auto), lang(Daytime), lang(Night)};
65 for(i = 0; i<3; i++) m_EarthRotation[i].Init(
66 TILE_UNIT*9+trw*i/5, TILE_UNIT+TILE_QUAD,
67 trw*(i+1)/5-trw*i/5-TILE_HALF, TILE_UNIT,
68 (char *)rotstr[i].c_str(), &m_TimeGroup, i ? &m_EarthRotation[i-1] : NULL);
69 m_RevLabel.Init(TILE_UNIT, TILE_UNIT*2+TILE_QUAD, TILE_UNIT*8, TILE_UNIT,
70 lang(Revolution_Season), &m_TimeGroup, 0, 1);
71 string revstr[5] = {lang(Auto), lang(Spring), lang(Summer), lang(Autumn), lang(Winter)};
72 for(i = 0; i<5; i++) m_EarthRevolution[i].Init(
73 TILE_UNIT*9+trw*i/5, TILE_UNIT*2+TILE_QUAD,
74 trw*(i+1)/5-trw*i/5-TILE_HALF, TILE_UNIT,
75 (char *)revstr[i].c_str(), &m_TimeGroup, i ? &m_EarthRevolution[i-1] : NULL);
76 m_MiscGroup.Init(TILE_UNIT, TILE_UNIT*16,
77 WW-TILE_UNIT*2, TILE_UNIT*4, lang(Miscellaneous), &m_SimulationWindow);
78 m_ManualControl.Init(TILE_UNIT, TILE_UNIT+TILE_QUAD, WW-TILE_UNIT*4, TILE_UNIT,
79 lang(ManualControl), &m_MiscGroup);
80 m_IgnoreAcceleration.Init(TILE_UNIT, TILE_UNIT*2+TILE_QUAD, WW-TILE_UNIT*4, TILE_UNIT,
81 lang(IgnoreAcceleration), &m_MiscGroup);
82 m_NoteLabel.Init(TILE_UNIT, WH-TILE_UNIT*2, wide, TILE_UNIT,
83 lang(SavedInEveryFile), &m_SimulationWindow, 0, 1);
84 InitTimeOption();
85 }
86
87 /*
88 * モードを有効化
89 */
90 void CSimulationMode::EnterInterface(){
91 ms_ModeLabel = lang(SimulationSetting);
92 int i;
93 for(i = 0; i<TIME_SCALE_MAX; i++) m_TimeScale[i].Enable(!g_NetworkInitialized);
94 m_ManualControl.Enable(!g_NetworkInitialized);
95 m_IgnoreAcceleration.Enable(!g_NetworkInitialized);
96 }
97
98 /*
99 * 入力チェック
100 */
101 void CSimulationMode::ScanInputInterface(){
102 m_Interface.ScanInput();
103 if(m_SimulationWindow.CheckClose()){
104 SetNeutral();
105 return;
106 }
107 int sp = m_SimSpeed->GetNumber();
108 if(sp) m_OldSpeed = sp;
109 }
110
111 /*
112 * 時間設定初期化
113 */
114 void CSimulationMode::InitTimeOption(){
115 m_TimeScale[3].SetCheck();
116 m_SimSpeed[m_OldSpeed = 1].SetCheck();
117 m_EarthRotation[0].SetCheck();
118 m_EarthRevolution[0].SetCheck();
119 m_ManualControl.SetCheck(0);
120 m_IgnoreAcceleration.SetCheck(0);
121 }
122
123 /*
124 * 時間軸スケール取得
125 */
126 int CSimulationMode::GetTimeScale(){
127 return SCALE_TABLE[m_TimeScale->GetNumber()];
128 }
129
130 /*
131 * シミュレーション速度取得
132 */
133 int CSimulationMode::GetSimSpeed(){
134 return SPEED_TABLE[m_SimSpeed->GetNumber()];
135 }
136
137 /*
138 * シミュレーション速度設定
139 */
140 void CSimulationMode::SetSimSpeed(
141 int sp // スピード
142 ){
143 if(0<=sp && sp<SIM_SPEED_NUM) m_SimSpeed[sp].SetCheck();
144 }
145
146 /*
147 * ポーズ切り替え
148 */
149 void CSimulationMode::TogglePause(){
150 int sp = m_SimSpeed->GetNumber();
151 if(sp){
152 m_OldSpeed = sp;
153 m_SimSpeed[0].SetCheck();
154 }else{
155 m_SimSpeed[m_OldSpeed].SetCheck();
156 }
157 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26