feat(ui): implement Script_GetScreenResolutions

This commit is contained in:
fallenoak 2025-11-09 17:20:40 -06:00
parent edd25251fb
commit 6ec4d2eae6
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D

View File

@ -1,12 +1,43 @@
#include "ui/game/CGVideoOptionsScript.hpp"
#include "ui/game/CGVideoOptions.hpp"
#include "console/CVar.hpp"
#include "console/Detect.hpp"
#include "ui/Types.hpp"
#include "ui/game/CGVideoOptions.hpp"
#include "util/Lua.hpp"
#include "util/Unimplemented.hpp"
#include <tempest/Vector.hpp>
static TSGrowableArray<C2iVector> s_screenResolutions;
void SetupResolutions() {
if (s_screenResolutions.Count()) {
return;
}
auto widescreenCvar = CVar::Lookup("widescreen");
int32_t widescreen = widescreenCvar ? widescreenCvar->GetInt() : 0;
ConsoleDetectGetResolutions(s_screenResolutions, widescreen);
}
int32_t Script_GetScreenResolutions(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
SetupResolutions();
lua_checkstack(L, s_screenResolutions.Count());
char resolutionStr[64];
for (uint32_t i = 0; i < s_screenResolutions.Count(); i++) {
auto& resolution = s_screenResolutions[i];
SStrPrintf(resolutionStr, sizeof(resolutionStr), "%dx%d", resolution.x, resolution.y);
lua_pushstring(L, resolutionStr);
}
return s_screenResolutions.Count();
}
int32_t Script_GetCurrentResolution(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}