X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FMainForm.c;h=5c3b85fda28de4470669981ae381b6fe7396c8c3;hb=0f5b7f63f2d3d75ba646795a3c1ea9fc4cee4845;hp=9cb124e5e92b3bf434ee5e1d0e9281318ecae64e;hpb=e63e92923fa0196ba7d538d4c8f5a16994e3bee8;p=rocksndiamonds.git diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 9cb124e5..5c3b85fd 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -7,6 +7,10 @@ #if 1 static void DrawFrame(int Delta); +static void ReStretch(float NewStretch); +static void picPane_Paint(); +static void picViewPort_Resize(); +static void menBorder_Click(); #else @@ -818,6 +822,9 @@ static void Let_LastSaveFilter(long NewVal) static void CountDown(long HalfSeconds, int bDisplayBar) { + +#if 0 + long i; int k; long dT, Delta; @@ -857,6 +864,9 @@ static void CountDown(long HalfSeconds, int bDisplayBar) shpProgress.Visible = False; // lblFrameCount = 0 + +#endif + } #if 0 @@ -997,13 +1007,18 @@ void DisplayLevel() { int X, Y; +#if 1 + printf("::: MainForm.c: DisplayLevel(): %d, %d, %d\n", + Loaded, LevelLoaded, bPlaying); +#endif + if (! Loaded) return; if (! LevelLoaded) return; -#if 0 +#if 1 SetDisplayRegion(); #endif @@ -1016,6 +1031,12 @@ void DisplayLevel() if (bPlaying) { +#if 1 + printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n", + DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, + FieldWidth, FieldHeight); +#endif + for (Y = DisplayMinY; Y <= DisplayMaxY; Y++) { for (X = DisplayMinX; X <= DisplayMaxX; X++) @@ -1094,8 +1115,8 @@ static void cmbLevel_Click() long InfoCount; boolean Oldflag; int Msg; - long LastIndex; - boolean bBlock; + static long LastIndex = 0; + static boolean bBlock = False; if (bBlock) return; @@ -1299,7 +1320,9 @@ static void Form_KeyUp(int KeyCode, int Shift) picPane_KeyUp(KeyCode, Shift); } -static void Form_Load() +#endif + +void Form_Load() { #if 0 @@ -1314,6 +1337,7 @@ static void Form_Load() EditFlag = False; EditMode = edMove; // FMark = New MarkerObject; // (handle this later, if needed) + InitGlobals(); #if 0 @@ -1340,14 +1364,22 @@ static void Form_Load() picViewPort.ScaleMode = vbPixels; +#endif + PauseMode = 0; // BaseWidth = 16 + menBorder_Click(); + Loaded = True; + ReStretch(Stretch); + +#if 0 + LoadKeyIndicators(); - Show; + Show(); FillFileList(CurPath); if (s.Read("ShowSplash", True)) @@ -1359,6 +1391,8 @@ static void Form_Load() #endif } +#if 0 + static void FillLevelList(char *Path, int LevelIndex) { long FNum, LevLen, i, iMax; @@ -1614,8 +1648,6 @@ static void DrawFrame(int Delta) } } -#if 0 - static void RestoreFrame() { int i, LX, tY, RX, BY; @@ -1637,6 +1669,8 @@ static void RestoreFrame() } } +#if 0 + static void Form_Unload(int Cancel) { EndFlag = True; @@ -1689,7 +1723,7 @@ static void Form_Unload(int Cancel) static void fpsTim_Timer() { currency TickDiff; - int count5; + static int count5 = 0; count5 = count5 + 1; if (4 < count5) @@ -1718,6 +1752,8 @@ static void menAutoScroll_Click() } } +#endif + static void menBorder_Click() { if (menBorder.Checked) @@ -1729,6 +1765,7 @@ static void menBorder_Click() DisplayMinY = 1; DisplayMaxY = FieldHeight - 2; DisplayHeight = FieldHeight; + if (Loaded && LevelLoaded) DrawFrame(1); @@ -1742,6 +1779,7 @@ static void menBorder_Click() DisplayMinY = 0; DisplayMaxY = FieldHeight - 1; DisplayHeight = FieldHeight + 2; + if (Loaded && LevelLoaded) RestoreFrame(); } @@ -1760,6 +1798,7 @@ void SetDisplayRegion() DisplayMinY = 1; DisplayMaxY = FieldHeight - 2; DisplayHeight = FieldHeight; + if (LevelLoaded) DrawFrame(1); @@ -1772,11 +1811,14 @@ void SetDisplayRegion() DisplayMinY = 0; DisplayMaxY = FieldHeight - 1; DisplayHeight = FieldHeight + 2; + if (LevelLoaded) RestoreFrame(); } } +#if 0 + static void menCopy_Click() { FMark.Copy; @@ -2083,7 +2125,7 @@ static void menPanel_Click() void Let_PanelVisible(boolean NewVal) { - boolean HidePanel; + static boolean HidePanel = False; if (HidePanel != NewVal) return; @@ -2119,8 +2161,8 @@ static void menPaste_Click() static void menPause_Click() { - StdPicture OldPic; - char *OldText; + static StdPicture OldPic; + static char *OldText = 0; PauseMode = (PauseMode != 0 ? 0 : 0); if (PauseMode != 0) @@ -2145,7 +2187,7 @@ static void menPlayAll_Click() int FNum; char *LogPath, *OutStr, *ReRecPath, *SPPath; boolean bEqual; - boolean QuitFlag; + static boolean QuitFlag = False; if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos") { @@ -2358,7 +2400,6 @@ static void menSoundFX_Click() // static void menPlay_Click() void menPlay_Click() { - #if 0 boolean OldEditFlag; @@ -2404,25 +2445,34 @@ void menPlay_Click() #endif LastFrame = 0; - LastTick = T.TickNow; #if 0 + LastTick = T.TickNow(); +#endif +#if 0 fpsTim.Enabled = True; - #endif // DimPrimary 100 bPlaying = True; #if 0 - UpdateDeltaT(); +#endif +#if 1 + printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): ...\n"); #endif subFetchAndInitLevelB(); +#if 1 + printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): done\n"); +#endif + + ReStretch(Stretch); + // Trace "MainForm", "CountDown 1" CountDown(2, (0 == DemoFlag)); // Trace "MainForm", "Call GoPlay" @@ -2894,6 +2944,8 @@ static void picPane_MouseUp(int Button, int Shift, float X, float Y) } } +#endif + static void picPane_Paint() { boolean Oldflag; @@ -2906,27 +2958,48 @@ static void picPane_Paint() static void ReStretch(float NewStretch) { +#if 1 + long BW2, LW, LH; +#else long BW2, LW, LH, i; +#endif + +#if 1 + printf("::: MainForm.c: ReStretch(): %d, %d\n", Loaded, LevelLoaded); +#endif if (! Loaded) { +#if 1 + printf("::: NewStretch == %f\n", NewStretch); +#endif + Stretch = NewStretch; return; } +#if 0 MousePointer = 11; SET_TO_NOTHING(&Stage, sizeof(Stage)); SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites)); menStretch(Stretch / 0.25).Checked = False; +#endif + Stretch = NewStretch; + +#if 0 menStretch(Stretch / 0.25).Checked = True; // StretchWidth = BaseWidth ' * NewStretch // StretchWidth2 = StretchWidth \ 2 // TwoPixels = 2 '* Stretch // StretchLoad Sprites, imgMpx.Picture, 16, 16 +#endif + BW2 = StretchWidth / 2; LW = (FieldWidth + 2) * BaseWidth; // StretchWidth LH = (FieldHeight + 2) * BaseWidth; // StretchWidth + +#if 0 // i = bmpStage.CreateAtSize(LW, LH) // Stage = New DDScrollBuffer; // (handle this later, if needed) i = Stage.CreateAtSize(LW, LH, picPane.hWnd); @@ -2940,38 +3013,66 @@ static void ReStretch(float NewStretch) } else +#endif { StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth Stage.DestXOff = 1 * StretchWidth; Stage.DestYOff = 1 * StretchWidth; StretchedSprites.DestinationSurface = Stage.Surface; - Stage.Cls; + +#if 0 + Stage.Cls(); +#endif + if (Loaded && LevelLoaded) { +#if 1 + printf("::: MainForm.c: ReStretch(): ...\n"); +#endif + SetDisplayRegion(); picViewPort_Resize(); DisplayLevel(); } subCalculateScreenScrollPos(); + +#if 1 + printf("::: MainForm.c: ReStretch(): %d, %d\n", ScreenScrollXPos, ScreenScrollYPos); +#endif + ScrollTo(ScreenScrollXPos, ScreenScrollYPos); + Stage.Blt(); + picPane_Paint(); } +#if 0 MousePointer = 0; +#endif } static void SetScrollEdges() { - ScrollMinX = (DisplayMinX - 0.5) * Stretch * BaseWidth; - ScrollMinY = (DisplayMinY - 0.5) * Stretch * BaseWidth; - ScrollMaxX = (DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width; - ScrollMaxY = (DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height; -} +#if 1 + printf("::: MainForm.c: SetScrollEdges() ... [%ld, %ld, %ld, %ld] [%f, %d] [%d, %d, %d, %d]\n", + DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, + Stretch, BaseWidth, + ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY); +#endif + + ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth; + ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth; + ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width; + ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height; +#if 1 + printf("::: MainForm.c: SetScrollEdges() done [%d, %d, %d, %d]\n", + ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY); #endif +} void DrawField(int X, int Y) { @@ -3057,6 +3158,11 @@ void DrawFieldNoAnimated(int X, int Y) Tmp = DisPlayField[tsi]; } +#if 0 + printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n", + X, Y, Tmp); +#endif + StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); break; } @@ -3090,8 +3196,11 @@ static void picViewPort_Paint() // Debug.Print "picViewPort_Paint()" } +#endif + static void picViewPort_Resize() { +#if 0 long bdX, bdY, PanelVisibility; long X, Y, dx, dY; SettingsObject s; @@ -3115,11 +3224,21 @@ static void picViewPort_Resize() Y = Max((picViewPort.ScaleHeight - dY) / 2, 0); picPane.Move X, Y, dx, dY; picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY; +#endif + SetScrollEdges(); + +#if 1 + printf("::: MainForm.c: picViewPort_Resize(): %d, %d\n", ScrollX, ScrollY); +#endif + ScrollTo(ScrollX, ScrollY); + // SizeTim.Interval = 1 } +#if 0 + // // Private Sub SizeTim_Timer() // Dim wdX&, wdY& @@ -3160,7 +3279,7 @@ void ShowKey(int KeyVar) int i; boolean Tmp; long Col; - boolean LastState[5 + 1]; + static boolean LastState[5 + 1]; // For i = 1 To 5 // State(i) = False