From ba1bce279e156145c2df53650c5220e1e2db4e29 Mon Sep 17 00:00:00 2001 From: jummy Date: Sat, 7 Sep 2024 21:26:29 -0500 Subject: [PATCH] weird weird --- src/blupi.cpp | 17 +- src/button.cpp | 370 +++++++++++++---------------- src/button.h | 4 +- src/decnet.cpp | 12 +- src/decor.cpp | 2 +- src/decor.h | 4 +- src/def.h | 13 +- src/event.cpp | 632 +++++++++++++++++++++++++++++++++++++++---------- src/event.h | 18 +- 9 files changed, 716 insertions(+), 356 deletions(-) diff --git a/src/blupi.cpp b/src/blupi.cpp index 6b61a47..8ba0794 100644 --- a/src/blupi.cpp +++ b/src/blupi.cpp @@ -38,7 +38,7 @@ #define TITLE "Blupi" #endif -#define MMTIMER TRUE +#define MMTIMER FALSE #define THREAD FALSE // Variables Globals @@ -438,6 +438,10 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, if (g_pEvent != NULL && g_pEvent->TreatEvent(message, wParam, lParam)) return 0; + char buf[25]; // DEBUG + sprintf(buf, "%d\n", message); + OutputDebug(buf); + switch (message) { case WM_TIMER: @@ -584,14 +588,17 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, return DefWindowProc(hWnd, message, wParam, lParam); } -LPTIMECALLBACK TimerStep() +void CALLBACK TimerStep(UINT wTimerID, UINT msg, + DWORD dwUser, DWORD dw1, DWORD dw2) { + char buf[20]; + sprintf(buf, "%d", wTimerID); + OutputDebug(buf); if (g_bActive && g_timer == 0) { g_timer = 1; - PostMessageA(g_hWnd, WM_UPDATE, 0, 0); + PostMessage(g_hWnd, WM_UPDATE, 0, 0); } - return NULL; } // Erreur dans DoInit. @@ -806,7 +813,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, Benchmark(); #if MMTIMER - g_updateTimer = timeSetEvent(g_timerInterval, g_timerInterval / 4, TimerStep(), NULL, TIME_PERIODIC); + g_updateTimer = timeSetEvent(g_timerInterval, g_timerInterval / 4, TimerStep, NULL, TIME_PERIODIC); #else SetTimer(g_hWnd, 1, g_timerInterval, NULL); #endif diff --git a/src/button.cpp b/src/button.cpp index f5c3b7c..1c512e9 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -5,7 +5,7 @@ #include #include #include -// #include + #include #include "def.h" #include "pixmap.h" @@ -22,18 +22,18 @@ using namespace std; CButton::CButton() { - m_type = 0; - m_bEnable = TRUE; - m_bHide = FALSE; - m_bSomething = FALSE; - m_state = 0; - m_mouseState = 0; - m_nbMenu = 0; - m_nbToolTips = 0; - m_selMenu = 0; - m_bMouseDown = FALSE; - m_bMinimizeRedraw = FALSE; - m_bRedraw = FALSE; + m_type = 0; + m_bEnable = TRUE; + m_bHide = FALSE; + m_bSomething = FALSE; + m_state = 0; + m_mouseState = 0; + m_nbMenu = 0; + m_nbToolTips = 0; + m_selMenu = 0; + m_bMouseDown = FALSE; + m_bMinimizeRedraw = FALSE; + m_bRedraw = FALSE; } // Destructor @@ -46,121 +46,77 @@ CButton::~CButton() // Create a new Button BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound, - POINT pos, int type, int* pMenu, int nbMenu, int *pToolTips, int nbToolTips, BOOL bMinimizeRedraw, int region, UINT message) + POINT pos, int type, int* pMenu, int nbMenu, int* pToolTips, int nbToolTips, BOOL bMinimizeRedraw, int region, UINT message) { - POINT iconDim; - int i, icon; + POINT iconDim; + int i, icon; - static int ttypes[] = - { - DIMBUTTONX,DIMBUTTONY, - }; - - if ( type < 0 || type > 0 ) return FALSE; - - iconDim.x = ttypes[type*2+0]; - iconDim.y = ttypes[type*2+1]; - - m_hWnd = hWnd; - m_pPixmap = pPixmap; - m_pSound = pSound; - m_type = type; - m_bMinimizeRedraw = bMinimizeRedraw; - m_bEnable = TRUE; - m_bHide = FALSE; - m_bSomething = FALSE; - m_message = message; - m_pos.x = pos.x; - m_pos.y = pos.y; - m_dim.x = iconDim.x; - m_dim.y = iconDim.y; - m_nbMenu = nbMenu; - m_nbToolTips = nbToolTips; - m_selMenu = 0; - m_state = 0; - m_mouseState = 0; - m_bMouseDown = FALSE; - m_bRedraw = TRUE; - -/* Do we need this yet? -/////////////////////////////////////////////////// - for ( i=0 ; i 0) return FALSE; - if ( region == 2 ) // hiver ? - { - if ( icon == 0 ) icon = 96; // sol normal - if ( icon == 1 ) icon = 97; // sol inflammable - if ( icon == 2 ) icon = 98; // sol inculte - if ( icon == 8 ) icon = 99; // arbre - } - if ( region == 3 ) // sapin ? - { - if ( icon == 0 ) icon = 102; // sol normal - if ( icon == 1 ) icon = 103; // sol inflammable - if ( icon == 2 ) icon = 104; // sol inculte - if ( icon == 8 ) icon = 105; // arbre - } - - m_iconMenu[i] = icon; - } - - for ( i=0 ; i 0) + if (0 < iconMenu) { - for (i = 0; i < somethingMenu; i++) + iconMenu2 = m_iconMenu; + for (i = 0; i < iconMenu; i++) { icon++; - m_iconMenu[i] = (int)icon; + m_iconMenu[i] = icon[i]; } } - m_nbMenu = somethingMenu; + m_nbMenu = iconMenu; } -void CButton::MenuToolTips(int* menu, int menuTooltips) +void CButton::SetToolTips(int* menu, int menuTooltips) { int toolTips; int* menuTool; int i; - if (menuTooltips > 0) + if (0 < menuTooltips) { menuTool = m_toolTips; i = menuTooltips; - do + for (i = 0; i < menuTooltips; i++) { - toolTips = *menu++; - *menuTool++ = toolTips; - --i; - } while (i); + menu++; + m_toolTips[i] = menu[i]; + } } m_nbToolTips = menuTooltips; } @@ -173,43 +129,43 @@ void CButton::Draw() POINT pos; RECT rect; - if ( m_bMinimizeRedraw && !m_bRedraw ) return; + if (m_bMinimizeRedraw && !m_bRedraw) return; m_bRedraw = FALSE, m_bSomething = FALSE; - if ( m_bHide ) // Hidden button + if (m_bHide) // Hidden button { - pos.y = m_pos.y; - pos.x = m_pos.x; + pos.y = m_pos.y; + pos.x = m_pos.x; return; } - if( m_bEnable ) + if (m_bEnable) { - m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_mouseState, m_pos); + m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, m_mouseState, m_pos); } else { - m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, 4, m_pos); + m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, 4, m_pos); } - if ( m_nbMenu == 0 ) return; + if (m_nbMenu == 0) return; pos = m_pos; - if ( m_nbMenu > 0 ) + if (m_nbMenu > 0) { - m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, - m_iconMenu[m_selMenu]+6, pos); + m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, + m_iconMenu[m_selMenu] + 6, pos); } - if ( m_nbMenu == 1 || !m_bEnable || !m_bMouseDown ) return; + if (m_nbMenu == 1 || !m_bEnable || !m_bMouseDown) return; pos = m_pos; - pos.x += m_dim.x+2; - for ( i=0 ; iDrawIcon(-1, CHBUTTON+m_type, i==m_selMenu?1:0, pos); - m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_iconMenu[i]+6, pos); - pos.x += m_dim.x-1; + m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, i == m_selMenu ? 1 : 0, pos); + m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, m_iconMenu[i] + 6, pos); + pos.x += m_dim.x - 1; } } @@ -218,7 +174,7 @@ void CButton::Draw() ////////////////////////////////////////////// void CButton::Redraw() { - m_bRedraw = TRUE; +m_bRedraw = TRUE; } ////////////////////////////////////////////// */ @@ -230,13 +186,13 @@ int CButton::GetState() void CButton::SetState(int state) { - if ( m_state != state || - m_mouseState != state ) + if (m_state != state || + m_mouseState != state) { m_bRedraw = TRUE; } - m_state = state; + m_state = state; m_mouseState = state; } @@ -247,7 +203,7 @@ int CButton::GetMenu() void CButton::SetMenu(int menu) { - if ( m_selMenu != menu ) + if (m_selMenu != menu) { m_bRedraw = TRUE; } @@ -257,7 +213,7 @@ void CButton::SetMenu(int menu) void CButton::SetEnable(BOOL bEnable) { - if ( m_bEnable != bEnable ) + if (m_bEnable != bEnable) { m_bRedraw = TRUE; } @@ -281,7 +237,7 @@ void CButton::SetSomething(BOOL bSomething) ///////////////////////////////////////// BOOL CButton::GetHide() { - return m_bHide; +return m_bHide; } ///////////////////////////////////////// */ @@ -289,7 +245,7 @@ BOOL CButton::GetHide() void CButton::SetHide(BOOL bHide) { - if ( m_bHide != bHide ) + if (m_bHide != bHide) { m_bRedraw = TRUE; } @@ -301,25 +257,25 @@ BOOL CButton::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam) { POINT pos; - if ( m_bHide || !m_bEnable ) return FALSE; + if (m_bHide || !m_bEnable) return FALSE; pos = ConvLongToPos(lParam); - switch( message ) + switch (message) { - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - if ( MouseDown(pos) ) return TRUE; - break; + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + if (MouseDown(pos)) return TRUE; + break; - case WM_MOUSEMOVE: - if ( MouseMove(pos) ) return TRUE; - break; - - case WM_LBUTTONUP: - case WM_RBUTTONUP: - if ( MouseUp(pos) ) return FALSE; - break; + case WM_MOUSEMOVE: + if (MouseMove(pos)) return TRUE; + break; + + case WM_LBUTTONUP: + case WM_RBUTTONUP: + if (MouseUp(pos)) return FALSE; + break; } return FALSE; @@ -342,27 +298,27 @@ int CButton::GetToolTips(POINT pos) int width = m_dim.x; int rank; - if ( m_bHide || !m_bEnable ) return -1; + if (m_bHide || !m_bEnable) return -1; - if ( m_nbMenu > 1 && m_bMouseDown ) // Drop-down submenu? + if (m_nbMenu > 1 && m_bMouseDown) // Drop-down submenu? { - width += 2+(m_dim.x-1)*m_nbMenu; + width += 2 + (m_dim.x - 1)*m_nbMenu; } - if ( pos.x < m_pos.x || - pos.x > m_pos.x+width || - pos.y < m_pos.y || - pos.y > m_pos.y+m_dim.y ) return -1; - - rank = (pos.x=-(m_pos.x+2+1))/(m_dim.x-1); - if ( rank < 0 ) rank = 0; - if ( rank > m_nbToolTips ) return -1; + if (pos.x < m_pos.x || + pos.x > m_pos.x + width || + pos.y < m_pos.y || + pos.y > m_pos.y + m_dim.y) return -1; - if ( m_nbMenu > 1 ) + rank = (pos.x = -(m_pos.x + 2 + 1)) / (m_dim.x - 1); + if (rank < 0) rank = 0; + if (rank > m_nbToolTips) return -1; + + if (m_nbMenu > 1) { - if ( m_bMouseDown && rank > 0 ) + if (m_bMouseDown && rank > 0) { - rank --; + rank--; } else { @@ -377,73 +333,71 @@ BOOL CButton::Detect(POINT pos) { int width = m_dim.x; - if ( m_bHide || !m_bEnable ) return FALSE; + if (m_bHide || !m_bEnable) return FALSE; - if ( m_nbMenu > 1 && m_bMouseDown ) + if (m_nbMenu > 1 && m_bMouseDown) { - width += 2+(m_dim.x-1)*m_nbMenu; + width += 2 + (m_dim.x - 1)*m_nbMenu; } - if ( pos.x < m_pos.x || - pos.x > m_pos.x+width || - pos.y < m_pos.y || - pos.y > m_pos.y+m_dim.y ) return FALSE; - - return TRUE; -} - -BOOL CButton::MouseDown(POINT pos) -{ - if ( !Detect(pos) ) return FALSE; - - m_mouseState = 1; - m_bMouseDown = TRUE; - m_bRedraw = TRUE; - PostMessage(m_hWnd, WM_UPDATE, 0, 0); + if (pos.x < m_pos.x || + pos.x > m_pos.x + width || + pos.y < m_pos.y || + pos.y > m_pos.y + m_dim.y) return FALSE; return TRUE; } BOOL CButton::MouseMove(POINT pos) { - BOOL bDetect; - int iState, iMenu; + int selMenu = m_selMenu; + int mouseState; + BOOL BVar3; + int iVar4; + int iVar5; + BOOL BVar6; + int iVar7; - iState = m_mouseState; - iMenu = m_selMenu; - - bDetect = Detect(pos); - - if ( m_bMouseDown ) - { - if ( bDetect ) m_mouseState = 1; - else m_mouseState = m_state; - } - else - { - if ( bDetect ) m_mouseState = m_state+2; - else m_mouseState = m_state; - } - - if ( m_nbMenu > 1 && - m_bMouseDown && - pos.x > m_pos.x+m_dim.x+2 ) - { - m_selMenu = (pos.x-(m_pos.x+m_dim.x+2))/(m_dim.x-1); - if ( m_selMenu >= m_nbMenu ) - { - m_selMenu = m_nbMenu-1; + mouseState = m_mouseState; + BVar6 = Detect(pos); + BVar3 = m_bMouseDown; + if (!m_bMouseDown) { + if (!Detect(pos)) { + m_mouseState = m_state; + } + else { + m_mouseState = m_state + 2; } } - - if ( iState != m_mouseState || - iMenu != m_selMenu ) - { - m_bRedraw = TRUE; - PostMessage(m_hWnd, WM_UPDATE, 0, 0); + else if (Detect(pos)) { + m_mouseState = 1; } + else { + m_mouseState = m_state; + } + if (m_nbMenu > 1 && m_bMouseDown) { + if ((m_pos.x + m_dim.x + 2 < pos.x)) + { + m_selMenu = (pos.x - m_pos.x - m_dim.x - 2) / (m_dim.x - 1); + if (m_selMenu >= m_nbMenu) m_selMenu = m_nbMenu - 1; + } + } + if (mouseState != m_mouseState || selMenu != m_selMenu) m_bRedraw = TRUE; + return BVar3; +} - return m_bMouseDown; + +BOOL CButton::MouseDown(POINT pos) +{ + if (!Detect(pos)) return FALSE; + + m_mouseState = 1; + m_bMouseDown = TRUE; + m_bRedraw = TRUE; + // PostMessage(m_hWnd, WM_UPDATE, 0, 0); + + m_pSound->PlayImage(SOUND_CLICK, pos); + return TRUE; } BOOL CButton::MouseUp(POINT pos) @@ -454,11 +408,11 @@ BOOL CButton::MouseUp(POINT pos) m_mouseState = m_state; m_bMouseDown = FALSE; - m_bRedraw = TRUE; + m_bRedraw = TRUE; - if ( !bDetect ) return FALSE; + if (!bDetect) return FALSE; - if ( m_message != -1 ) + if (m_message != -1) { PostMessage(m_hWnd, m_message, 0, 0); } diff --git a/src/button.h b/src/button.h index 8b54053..3237937 100644 --- a/src/button.h +++ b/src/button.h @@ -14,8 +14,8 @@ public: BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound, POINT pos, int type, int* pMenu, int nbMenu, int* pToolTips, int nbToolTips, BOOL bMinimizeRedraw, int region, UINT message); - void SetSomethingMenu(int* icon, int somethingMenu); - void MenuToolTips(int* menu, int menuTooltips); + void SetIconMenu(int* icon, int iconMenu); + void SetToolTips(int* menu, int menuTooltips); void Draw(); void Redraw(); diff --git a/src/decnet.cpp b/src/decnet.cpp index 4767c76..2f6efd4 100644 --- a/src/decnet.cpp +++ b/src/decnet.cpp @@ -53,7 +53,7 @@ void CDecor::NetDataFlush() m_netIcons[i] = -1; m_netUnk1[i] = 0; m_netUnk2[i] = 0; - m_netUnk3[i] = 0; + m_netTransports[i] = 0; m_netPlayerPacketsReceived[i] = 0; m_netPlayerPacketsReceived2[i] = 0; m_netTimeSincePacket[i] = 0; @@ -87,9 +87,15 @@ void CDecor::DoNetSmooth(int player) } -void CDecor::NetFUN_15d50() +void CDecor::NetAdjustToLift() { - + for (int i = 0; i < MAXNETPLAYER; i++) + { + if (m_netPos[i].x != -1 && m_netTransports[i] >= 0 && m_netTransports[i] < MAXMOVEOBJECT) + { + m_netPos[i].y = m_moveObject[m_netTransports[i]].posCurrent.y - 58; + } + } } void CDecor::FUN_15da0(int index, short step) diff --git a/src/decor.cpp b/src/decor.cpp index 46dc075..8cb0998 100644 --- a/src/decor.cpp +++ b/src/decor.cpp @@ -368,7 +368,7 @@ void CDecor::MoveStep() if (m_phase == WM_PHASE_PLAY || m_phase == WM_PHASE_PLAYTEST) { BlupiStep(); - NetFUN_15d50(); + NetAdjustToLift(); NotifStep(); } diff --git a/src/decor.h b/src/decor.h index 4838a65..a747f29 100644 --- a/src/decor.h +++ b/src/decor.h @@ -253,7 +253,7 @@ public: void NetFUN_155e0(BYTE _foo, short _bar); void TreatNetData(); void DoNetSmooth(int player); - void NetFUN_15d50(); + void NetAdjustToLift(); void FUN_15da0(int rank, short step); void NetPlayerCollide(POINT pos, int *out); void NetMessageIndexFlush(); @@ -375,7 +375,7 @@ protected: int m_netIcons[MAXNETPLAYER]; int m_netUnk1[MAXNETPLAYER]; int m_netUnk2[MAXNETPLAYER]; - int m_netUnk3[MAXNETPLAYER]; + int m_netTransports[MAXNETPLAYER]; // index of lift ridden by each player, or -1 int m_netPlayerPacketsReceived[MAXNETPLAYER]; int m_netPlayerPacketsReceived2[MAXNETPLAYER]; int m_netTimeSincePacket[MAXNETPLAYER]; diff --git a/src/def.h b/src/def.h index 819140d..59e0c6f 100644 --- a/src/def.h +++ b/src/def.h @@ -475,6 +475,11 @@ enum { WM_BUTTON38, WM_BUTTON39, + WM_DIMS1, + WM_DIMS2, + WM_DIMS3, + WM_DIMS4, + WM_READ0 = WM_USER + 300, WM_READ1, WM_READ2, @@ -534,12 +539,12 @@ enum { WM_PHASE_WRITEDESIGN, WM_PHASE_READDESIGN, WM_PHASE_CLEARDESIGN, - WM_PHASE_1562, - WM_PHASE_1563, - WM_PHASE_1564, + WM_PHASE_DONAMEGAMER, + WM_PHASE_DOCLEARGAMER, + WM_PHASE_DONAMEDESIGN, WM_PHASE_1565, WM_PHASE_1566, - WM_PHASE_1567, + WM_PHASE_DOCLEARDESIGN, WM_PHASE_SERVICE, WM_PHASE_DPLAY_DO_SERVICE, WM_PHASE_DPLAY_CANCEL_SERVICE, diff --git a/src/event.cpp b/src/event.cpp index 4114ceb..9bbd6a6 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -263,7 +263,7 @@ static Phase table[] = FALSE, { { - WM_PHASE_1562, + WM_PHASE_DONAMEGAMER, 0,{ 1, IC_BT_ACCEPT }, 0xde, 0x146, { 1, 0xae } @@ -283,7 +283,7 @@ static Phase table[] = FALSE, { { - WM_PHASE_1563, + WM_PHASE_DONAMEDESIGN, 0,{ 1, IC_BT_ACCEPT }, 0xde, 0x146, { 1, 0xb0 } @@ -651,8 +651,8 @@ BOOL CEvent::CreateButtons() { iconMenu++; } - m_buttons->SetSomethingMenu(table[m_index].buttons[i].iconMenu + i + 4, *(int*)iconMenu); - m_buttons->MenuToolTips(table[m_index].buttons[i].toolTips + i + 4, *(int*)table[m_index].buttons[i].toolTips + i); + m_buttons->SetIconMenu(table[m_index].buttons[i].iconMenu + i + 4, *(int*)iconMenu); + m_buttons->SetToolTips(table[m_index].buttons[i].toolTips + i + 4, *(int*)table[m_index].buttons[i].toolTips + i); } } @@ -1432,132 +1432,72 @@ BOOL CEvent::TreatEventBase(UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_KEYDOWN: - if (wParam >= 'A' && wParam <= 'Z') - { - if (m_posCheat == 0) - { - m_rankCheat = -1; - - for (i = 0; i < 9; i++) - { - if ((char)wParam == cheat_code[i][0]) - { - m_rankCheat = i; - break; - } - } - } - if (m_rankCheat != -1) - { - c = cheat_code[m_rankCheat][m_posCheat]; - if (m_posCheat != 0 && m_rankCheat == 0) c++; - if ((char)wParam == c) - { - m_posCheat++; - - } - } - - if (m_phase != WM_PHASE_PLAY) - { - ChangePhase(m_phase); - } - if (bEnable) - { - pos.x = 320; - pos.y = LYIMAGE / 2; - m_pSound->PlayImage(SOUND_JUMPEND, pos, -1); - } - else - { - pos.x = 320; - pos.y = LYIMAGE / 2; - m_pSound->PlayImage(SOUND_RESSORT, pos, -1); - } - m_rankCheat = -1; - m_posCheat = 1; - } - return TRUE; - - if (m_phase == WM_PHASE_INIT) - { - ChangePhase(WM_PHASE_INIT); - return TRUE; - } - - if (m_phase == WM_PHASE_BYE) - { - PostMessageA(m_hWnd, WM_CLOSE, 0, 0); - } switch (wParam) { - case VK_END: - DemoRecStop(); + case VK_END: + DemoRecStop(); + return TRUE; + case VK_ESCAPE: + if (m_bRunMovie) + { + StopMovie(); + m_pSound->SetSuspendSkip(1); return TRUE; - case VK_ESCAPE: - if (m_bRunMovie) + } + if (m_phase != WM_PHASE_PLAYTEST) + { + if (m_phase != WM_PHASE_SETUP) { - StopMovie(); - m_pSound->SetSuspendSkip(1); - return TRUE; - } - if (m_phase != WM_PHASE_PLAYTEST) - { - if (m_phase != WM_PHASE_SETUP) + if (m_phase != WM_PHASE_NAMEGAMER) { - if (m_phase != WM_PHASE_NAMEGAMER) + if (m_phase == WM_PHASE_NAMEDESIGN) { - if (m_phase == WM_PHASE_NAMEDESIGN) + m_pDecor->SetMissionTitle(m_textInput); + ChangePhase(WM_PHASE_INFO); + return TRUE; + } + if ((m_phase == WM_PHASE_INIT) || (m_phase == WM_PHASE_WINMULTI)) ChangePhase(WM_PHASE_GAMER); return TRUE; + if ((m_phase == WM_PHASE_BUILD) || ((m_phase == WM_PHASE_LOSTDESIGN || m_phase == WM_PHASE_LOST))) ChangePhase(WM_PHASE_INFO); return TRUE; + if (((m_phase != WM_PHASE_INFO) && (m_phase != WM_PHASE_STOP)) && (m_phase != WM_PHASE_HELP)) + { + if (m_phase == WM_PHASE_SERVICE) { - m_pDecor->SetMissionTitle(m_textInput); - ChangePhase(WM_PHASE_INFO); + ChangePhase(WM_PHASE_DPLAY_DO_SERVICE); return TRUE; } - if ((m_phase == WM_PHASE_INIT) || (m_phase == WM_PHASE_WINMULTI)) ChangePhase(WM_PHASE_GAMER); return TRUE; - if ((m_phase == WM_PHASE_BUILD) || ((m_phase == WM_PHASE_LOSTDESIGN || m_phase == WM_PHASE_LOST))) ChangePhase(WM_PHASE_INFO); return TRUE; - if (((m_phase != WM_PHASE_INFO) && (m_phase != WM_PHASE_STOP)) && (m_phase != WM_PHASE_HELP)) + if (m_phase == WM_PHASE_CREATE) { - if (m_phase == WM_PHASE_SERVICE) - { - ChangePhase(WM_PHASE_DPLAY_DO_SERVICE); - return TRUE; - } - if (m_phase == WM_PHASE_CREATE) - { - ChangePhase(WM_PHASE_DPLAY_CREATE); - return TRUE; - } - if (m_phase == WM_PHASE_MULTI) - { - ChatSend(); - return TRUE; - } - if (((m_phase != WM_PHASE_GREAD) && (m_phase != WM_PHASE_GREADp)) || ((m_fileIndex < 0 || LoadState(m_fileIndex) == FALSE))) - { - if (m_phase != WM_PHASE_GWRITE) return TRUE; - - if (m_fileIndex < 0) return TRUE; - - if (SaveState(m_fileIndex) == FALSE) return TRUE; - } + ChangePhase(WM_PHASE_DPLAY_CREATE); + return TRUE; + } + if (m_phase == WM_PHASE_MULTI) + { + ChatSend(); + return TRUE; + } + if (((m_phase != WM_PHASE_GREAD) && (m_phase != WM_PHASE_GREADp)) || ((m_choiceIndex < 0 || LoadState(m_choiceIndex) == FALSE))) + { + if (m_phase != WM_PHASE_GWRITE) return TRUE; + + if (m_choiceIndex < 0) return TRUE; + + if (SaveState(m_choiceIndex) == FALSE) return TRUE; } } } - strcpy(m_gamerName, m_textInput); } + strcpy(m_gamerName, m_textInput); + } } - } + if (m_phase != WM_PHASE_PLAY && m_phase != WM_PHASE_PLAYTEST) + { + return FALSE; + } + // Unknown Function - if (m_phase != WM_PHASE_PLAY && m_phase != WM_PHASE_PLAYTEST) - { - return 0; - } - // Unknown Function - - switch (wParam) - { + case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: m_bMouseDown = TRUE; MouseSprite(pos); @@ -1568,9 +1508,278 @@ BOOL CEvent::TreatEventBase(UINT message, WPARAM wParam, LPARAM lParam) } if (m_phase == WM_PHASE_PLAY) { - // if (PlayDown(pos, fwKeys)) return TRUE; + // if (PlayDown(pos, fwKeys)) return TRUE; } break; + case WM_MOUSEMOVE: + if (m_mouseType == MOUSETYPEGRA) + { + if (m_bShowMouse) + { + ShowCursor(FALSE); // cache la souris + m_pPixmap->MouseShow(TRUE); // montre sprite + m_bShowMouse = FALSE; + } + } + if (m_mouseType == MOUSETYPEWINPOS && + (pos.x != m_oldMousePos.x || + pos.y != m_oldMousePos.y)) + { + m_oldMousePos = pos; + ClientToScreen(m_hWnd, &m_oldMousePos); + SetCursorPos(m_oldMousePos.x, m_oldMousePos.y); // (*) + } + m_oldMousePos = pos; + + MouseSprite(pos); + if (EventButtons(message, wParam, lParam)) return TRUE; + if (m_phase == WM_PHASE_BUILD) + { + //if (BuildMove(pos, fwKeys)) return TRUE; + } + if (m_phase == WM_PHASE_PLAY) + { + //if (PlayMove(pos, fwKeys)) return TRUE; + } + break; + + case WM_NCMOUSEMOVE: + if (m_mouseType == MOUSETYPEGRA) + { + if (!m_bShowMouse) + { + ShowCursor(TRUE); // montre la souris + m_pPixmap->MouseShow(FALSE); // cache sprite + m_bShowMouse = TRUE; + } + } + break; + + case WM_LBUTTONUP: + case WM_RBUTTONUP: + m_bMousePress = FALSE; + if (EventButtons(message, wParam, lParam)) return TRUE; + if (m_phase == WM_PHASE_BUILD) + { + //if (BuildUp(pos, fwKeys)) return TRUE; + } + if (m_phase == WM_PHASE_PLAY) + { + //if (PlayUp(pos, fwKeys)) return TRUE; + } + if (m_phase == WM_PHASE_BYE) + { + PostMessage(m_hWnd, WM_CLOSE, 0, 0); + } + break; + case WM_PHASE_INTRO1: + case WM_PHASE_INTRO2: + case WM_PHASE_INIT: + case WM_PHASE_PLAY: + case WM_PHASE_BUILD: + case WM_PHASE_NAMEGAMER: + case WM_PHASE_CLEARGAMER: + case WM_PHASE_INFO: + case WM_PHASE_PLAYTEST: + case WM_PHASE_SETUP: + case WM_PHASE_MUSIC: + case WM_PHASE_PLAYMOVIE: + case WM_PHASE_WINMOVIE: + case WM_PHASE_SETUPp: + case WM_PHASE_REGION: + case WM_PHASE_GAMER: + case WM_PHASE_WINMOVIEDESIGN: + case WM_PHASE_WINMOVIEMULTI: + case WM_PHASE_BYE: + case WM_PHASE_NAMEDESIGN: + case WM_PHASE_WRITEDESIGN: + case WM_PHASE_READDESIGN: + case WM_PHASE_CLEARDESIGN: + case WM_PHASE_SERVICE: + case WM_PHASE_DPLAY_DO_SERVICE: + case WM_PHASE_DPLAY_CANCEL_SERVICE: + case WM_PHASE_SESSION: + case WM_PHASE_1572: + case WM_PHASE_DPLAY_CREATE_LOBBY: + case WM_PHASE_DPLAY_REFRESH: + case WM_PHASE_DPLAY_CANCEL_SESSION: + case WM_PHASE_MULTI: + case WM_PHASE_DPLAY_START_GAME_2: + case WM_PHASE_DPLAY_CANCEL_MULTI: + case WM_PHASE_CREATE: + case WM_PHASE_DPLAY_CREATE: + case WM_PHASE_DPLAY_CANCEL_CREATE: + case WM_PHASE_STOP: + case WM_PHASE_HELP: + case WM_PHASE_GWRITE: + case WM_PHASE_GREADp: + case WM_PHASE_GREAD: + case WM_PHASE_DOQUIT: + case WM_PHASE_1588: + if (ChangePhase(message)) return TRUE; + break; + case WM_PHASE_DOPLAY: + //TODO + break; + case WM_PHASE_PRIVATE: + // + break; + case WM_PHASE_DEMO: + m_demoNumber = 0; + DemoPlayStart(); + break; + case WM_PHASE_DONAMEGAMER: + case WM_PHASE_DOCLEARGAMER: + case WM_PHASE_DONAMEDESIGN: + case WM_PHASE_1565: + case WM_PHASE_1566: + case WM_PHASE_DOCLEARDESIGN: + ChangeButtons(message); + return FALSE; + case WM_PREV: // TODO: further is mostly copied from pb + if (m_bPrivate) + { + if (m_private > 0) + { + m_private--; + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + else if (m_bSchool) + { + if (m_exercice > 0) + { + m_exercice--; + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + else + { + if (m_mission > 0) + { + m_mission--; + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + break; + + case WM_NEXT: + if (m_bPrivate) + { + if (m_private < 20 - 1) + { + m_private++; + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + else if (m_bSchool) + { + if (m_exercice < 99) + { + m_exercice++; + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + else + { + if (m_mission < 99) + { + m_mission++; + if (m_maxMission < m_mission) + { + m_maxMission = m_mission; + } + if (ChangePhase(WM_PHASE_INFO)) return TRUE; + } + } + break; + + case WM_DECOR1: + SetState(WM_DECOR1, 1); + SetState(WM_DECOR2, 0); + SetState(WM_DECOR3, 0); + SetState(WM_DECOR4, 0); + SetState(WM_DECOR5, 0); + break; + + case WM_DECOR2: + SetState(WM_DECOR1, 0); + SetState(WM_DECOR2, 1); + SetState(WM_DECOR3, 0); + SetState(WM_DECOR4, 0); + SetState(WM_DECOR5, 0); + break; + + case WM_DECOR3: + SetState(WM_DECOR1, 0); + SetState(WM_DECOR2, 0); + SetState(WM_DECOR3, 1); + SetState(WM_DECOR4, 0); + SetState(WM_DECOR5, 0); + break; + + case WM_DECOR4: + SetState(WM_DECOR1, 0); + SetState(WM_DECOR2, 0); + SetState(WM_DECOR3, 0); + SetState(WM_DECOR4, 1); + SetState(WM_DECOR5, 0); + break; + + case WM_DECOR5: + SetState(WM_DECOR1, 0); + SetState(WM_DECOR2, 0); + SetState(WM_DECOR3, 0); + SetState(WM_DECOR4, 0); + SetState(WM_DECOR5, 1); + break; + + case WM_BUTTON0: + case WM_BUTTON1: + case WM_BUTTON2: + case WM_BUTTON3: + case WM_BUTTON4: + case WM_BUTTON5: + case WM_BUTTON6: + case WM_BUTTON7: + case WM_BUTTON8: + case WM_BUTTON9: + case WM_BUTTON10: + case WM_BUTTON11: + case WM_BUTTON12: + case WM_BUTTON13: + case WM_BUTTON14: + case WM_BUTTON15: + case WM_BUTTON16: + case WM_BUTTON17: + case WM_BUTTON18: + case WM_BUTTON19: + case WM_BUTTON20: + case WM_BUTTON21: + case WM_BUTTON22: + case WM_BUTTON23: + case WM_BUTTON24: + case WM_BUTTON25: + case WM_BUTTON26: + case WM_BUTTON27: + case WM_BUTTON28: + case WM_BUTTON29: + case WM_BUTTON30: + case WM_BUTTON31: + case WM_BUTTON32: + case WM_BUTTON33: + case WM_BUTTON34: + case WM_BUTTON35: + case WM_BUTTON36: + case WM_BUTTON37: + case WM_BUTTON38: + case WM_BUTTON39: + ChangeButtons(message); + break; + case WM_MOVIE: + StartMovie("movie\\essai.avi"); + ChangePhase(WM_PHASE_INIT); + break; } return FALSE; @@ -1856,13 +2065,13 @@ void CEvent::ReadAll() BOOL bPrivate; BOOL bMission; - if ((-1 < m_fileIndex) && (*(int*)((int)(m_filenameBuffer + -1) + m_fileIndex * 4 + 216) != 0)) + if ((-1 < m_choiceIndex) && (*(int*)((int)(m_filenameBuffer + -1) + m_choiceIndex * 4 + 216) != 0)) { //mission = m_pDecor->MissionStart(m_gamer, 999, bUser); if (mission != FALSE) { - read = m_pDecor->Read(m_gamer, m_fileIndex, &bMission, &bPrivate); + read = m_pDecor->Read(m_gamer, m_choiceIndex, &bMission, &bPrivate); if (read != FALSE) { @@ -2207,11 +2416,7 @@ void CEvent::SetLives(int lives) void CEvent::SetSpeed(int speed) { - int max; - - if ( m_bSpeed ) max = 2; - - if ( speed > max ) speed = max; + if ( speed > 2 ) speed = 2; m_speed = speed; } @@ -2540,3 +2745,190 @@ BOOL CEvent::ReadPlayer() return TRUE; } +void CEvent::ChangeButtons(int message) +{ + if (m_phase == WM_PHASE_GAMER && message >= WM_BUTTON1 && message <= WM_BUTTON10) + { + m_gamer = message - WM_BUTTON0; + for (int i = 0; i < 10; i++) + { + SetState(WM_BUTTON1 + i, i == m_gamer - 1); + } + ReadInfo(m_gamer); + } + if (m_phase == WM_PHASE_NAMEGAMER && message == WM_PHASE_DONAMEGAMER) + { + WriteInfo(m_gamer, m_textInput); + ChangePhase(WM_PHASE_GAMER); + } + if (m_phase == WM_PHASE_NAMEDESIGN && message == WM_PHASE_DONAMEDESIGN) + { + m_pDecor->SetMissionTitle(m_textInput); + ChangePhase(WM_PHASE_INFO); + } + if (m_phase == WM_PHASE_CLEARGAMER && message == WM_PHASE_DOCLEARGAMER) + { + ClearGamer(m_gamer); + ChangePhase(WM_PHASE_GAMER); + } + if (m_phase == WM_PHASE_CLEARDESIGN && message == WM_PHASE_DOCLEARDESIGN) + { + m_pDecor->SomethingMissionPath(m_gamer, GetWorld(), !m_bBuildOfficialMissions); + ChangePhase(WM_PHASE_INFO); + } + if (m_phase == WM_PHASE_MUSIC) + { + m_pDecor->SetMusic(message - WM_BUTTON0); + ChangePhase(m_phase); + } + if (m_phase == WM_PHASE_REGION) + { + if (message >= WM_BUTTON1 && message <= WM_BUTTON32) + { + m_pDecor->SetRegion(message - WM_BUTTON1); + } + if (message >= WM_DIMS1 && message <= WM_DIMS4) + { + SetState(WM_DIMS1, 0); + SetState(WM_DIMS2, 0); + SetState(WM_DIMS3, 0); + SetState(WM_DIMS4, 0); + SetState(message, 1); + if (message == WM_DIMS1) m_pDecor->SetDim({ MAXCELX, MAXCELY }); + if (message == WM_DIMS2) m_pDecor->SetDim({ MAXCELX, 0 }); + if (message == WM_DIMS3) m_pDecor->SetDim({ 0, MAXCELY }); + if (message == WM_DIMS4) m_pDecor->SetDim({ 0, 0 }); + } + } + if (m_phase == WM_PHASE_SERVICE) + { + if (message >= WM_BUTTON1 && message <= WM_BUTTON6) + { + m_choiceIndex = message - WM_BUTTON1 + m_choicePageOffset; + } + if (message == WM_BUTTON10) + { + m_choicePageOffset -= 6; + if (m_choicePageOffset < 0) m_choicePageOffset = 0; + } + if (message == WM_BUTTON11) + { + m_choicePageOffset += 6; + } + SetHide(WM_BUTTON10, m_choicePageOffset == 0); + SetHide(WM_BUTTON11, (m_nbChoices + 5) / 6 * 6 <= m_choicePageOffset + 6); + for (int i = 0; i < 6; i++) + { + if (m_choicePageOffset + i < m_nbChoices) + { + SetHide(WM_BUTTON1 + i, FALSE); + SetState(WM_BUTTON1 + i, m_choicePageOffset == m_choiceIndex); + } + else + { + SetHide(WM_BUTTON1 + i, TRUE); + } + } + } + if (m_phase == WM_PHASE_SESSION) + { + if (message >= WM_BUTTON1 && message <= WM_BUTTON6) + { + m_choiceIndex = message - WM_BUTTON1 + m_choicePageOffset; + } + if (message == WM_BUTTON10) + { + m_choicePageOffset -= 6; + if (m_choicePageOffset < 0) m_choicePageOffset = 0; + } + if (message == WM_BUTTON11) + { + m_choicePageOffset += 6; + } + SetHide(WM_BUTTON10, m_choicePageOffset == 0); + SetHide(WM_BUTTON11, (m_nbChoices + 5) / 6 * 6 <= m_choicePageOffset + 6); + for (int i = 0; i < 6; i++) + { + if (m_choicePageOffset + i < m_nbChoices) + { + SetHide(WM_BUTTON1 + i, FALSE); + SetState(WM_BUTTON1 + i, m_choicePageOffset == m_choiceIndex); + } + else + { + SetHide(WM_BUTTON1 + i, TRUE); + } + } + } + if (m_phase == WM_PHASE_MULTI) + { + if (message >= WM_BUTTON1 && message <= WM_BUTTON4) + { + if (m_pNetwork->m_players[message - WM_BUTTON1].team >= MAXNETPLAYER) + { + m_pNetwork->m_players[message - WM_BUTTON1].team = 0; + } + + if (m_pNetwork->IsHost()) + { + NetSendLobby(); + } + else + { + //TODO + //m_pNetwork->Send(... + } + //DrawMap(); + //NetAdjustLobbyButtons(); + } + if (message >= WM_BUTTON11 && message <= WM_BUTTON14) + { + m_pNetwork->m_players[message - WM_BUTTON11].ready ^= 1; // toggle ready + if (m_pNetwork->IsHost()) + { + NetSendLobby(); + } + else + { + //TODO + //m_pNetwork->Send(... + } + //NetAdjustLobbyButtons(); + } + if (message == WM_BUTTON20) + { + ChatSend(); + } + } + if (m_phase == WM_PHASE_READDESIGN) + { + //TODO + } + if (m_phase == WM_PHASE_WRITEDESIGN) + { + //TODO + } + if (m_phase == WM_PHASE_GREAD || m_phase == WM_PHASE_GREADp) + { + //TODO + } + if (m_phase == WM_PHASE_GWRITE) + { + //TODO + } + if (m_phase == WM_PHASE_SETUP || m_phase == WM_PHASE_SETUPp) + { + //TODO + } +} + +BOOL CEvent::ClearGamer(int gamer) +{ + char filename[260]; + + m_6D30 = 0; + sprintf(filename, "data\\info%.3d.blp", gamer); + AddUserPath(filename); + remove(filename); + return TRUE; +} \ No newline at end of file diff --git a/src/event.h b/src/event.h index 385c2ae..1e0c7fc 100644 --- a/src/event.h +++ b/src/event.h @@ -118,11 +118,6 @@ public: void FlushInput(); - BOOL FlipObject(); - - void Read(int message); - void Write(int message); - void SetSpeed(int speed); int GetSpeed(); BOOL GetPause(); @@ -141,7 +136,7 @@ public: BOOL SaveState(int rank); void SomethingUserMissions(char* lpFilename, LPCSTR fileSomething); - + BOOL ClearGamer(int gamer); protected: void DrawTextCenter(int res, int x, int y, int font=0); @@ -151,11 +146,8 @@ protected: int SearchPhase(UINT phase); void DecorShift(int dx, int dy); - BOOL PlayDown(POINT pos, int fwKeys); - BOOL PlayMove(POINT pos, int fwKeys); - BOOL PlayUp(POINT pos, int fwKeys); void ChangeButtons(int message); - + void BuildFloor(POINT cel, int insIcon); void BuildWater(POINT cel, int insIcon); BOOL BuildDown(POINT pos, int fwKeys, BOOL bMix=TRUE); @@ -203,7 +195,7 @@ protected: char m_gamerNameList[10][100]; void* m_somethingJoystick; int m_menuIndex; - int m_fileIndex; + int m_choiceIndex; int m_saveIndex; int m_menuDecor[10]; BOOL m_bMouseRelease; @@ -299,6 +291,10 @@ protected: HINSTANCE m_hInstance; char m_chatZone[100][5]; char m_text[100]; + + int m_choicePageOffset; + int m_nbChoices; + int m_6D30; }; extern