diff options
| -rw-r--r-- | assets/scripts/local2P.lua | 6 | ||||
| -rw-r--r-- | assets/scripts/mainMenu.lua | 3 | ||||
| -rw-r--r-- | assets/scripts/multiplayer.lua | 6 | ||||
| -rw-r--r-- | assets/scripts/settings.lua | 6 | ||||
| -rw-r--r-- | src/main.cpp | 18 |
5 files changed, 27 insertions, 12 deletions
diff --git a/assets/scripts/local2P.lua b/assets/scripts/local2P.lua new file mode 100644 index 0000000..5f5c233 --- /dev/null +++ b/assets/scripts/local2P.lua @@ -0,0 +1,6 @@ +---@diagnostic disable: undefined-global +function Setup() +end + +function Update() +end
\ No newline at end of file diff --git a/assets/scripts/mainMenu.lua b/assets/scripts/mainMenu.lua index fcefca6..b6688bc 100644 --- a/assets/scripts/mainMenu.lua +++ b/assets/scripts/mainMenu.lua @@ -12,12 +12,15 @@ function Setup() end function Local2PButton() + -- Add C functions to reset Lua state and re-run Setup with different scripts end function MultiplayerButton() + -- Add C functions to reset Lua state and re-run Setup with different scripts end function SettingsButton() + -- Add C functions to reset Lua state and re-run Setup with different scripts end function Update() diff --git a/assets/scripts/multiplayer.lua b/assets/scripts/multiplayer.lua new file mode 100644 index 0000000..5f5c233 --- /dev/null +++ b/assets/scripts/multiplayer.lua @@ -0,0 +1,6 @@ +---@diagnostic disable: undefined-global +function Setup() +end + +function Update() +end
\ No newline at end of file diff --git a/assets/scripts/settings.lua b/assets/scripts/settings.lua new file mode 100644 index 0000000..5f5c233 --- /dev/null +++ b/assets/scripts/settings.lua @@ -0,0 +1,6 @@ +---@diagnostic disable: undefined-global +function Setup() +end + +function Update() +end
\ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 5a495f3..6e79ff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,9 @@ SDL_Renderer* renderer = nullptr; SDL_Event event; TTF_Font* globalFont = nullptr; +// Colors +SDL_Color veryDarkGrey = {30, 30, 47, 255}; + struct QueuedTexture { SDL_Texture* texture; int x; @@ -268,15 +271,7 @@ int main() { for (const auto& button: buttonList) { if (x > button.rect.x && x < button.rect.x + button.rect.w && y > button.rect.y && y < button.rect.y + button.rect.h) { - lua_getglobal(L, button.callback.c_str()); - if (lua_isfunction(L, -1)) { - if (lua_pcall(L, 0, 0, 0) != LUA_OK) { - std::cerr << "Lua Error in button callback: " << lua_tostring(L, -1) << std::endl; - lua_pop(L, 1); - } - } else { - lua_pop(L, 1); - } + call_lua_function(L, button.callback.c_str()); } } } @@ -314,8 +309,7 @@ int main() { SDL_SetRenderDrawColor(renderer, 252, 210, 77, 255); SDL_RenderFillRect(renderer, &button.rect); if (globalFont) { - SDL_Color white = {255, 255, 255, 255}; - SDL_Surface* textSurface = TTF_RenderText_Blended(globalFont, button.text.c_str(), white); + SDL_Surface* textSurface = TTF_RenderText_Blended(globalFont, button.text.c_str(), veryDarkGrey); if (textSurface) { SDL_Texture* textTexture = SDL_CreateTextureFromSurface(renderer, textSurface); SDL_Rect textRect; @@ -333,7 +327,7 @@ int main() { } } } - + buttonList.clear(); SDL_RenderPresent(renderer); SDL_Delay(10); |
