mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
feat(ui): implement Script_GetScreenResolutions
This commit is contained in:
parent
edd25251fb
commit
6ec4d2eae6
@ -1,12 +1,43 @@
|
|||||||
#include "ui/game/CGVideoOptionsScript.hpp"
|
#include "ui/game/CGVideoOptionsScript.hpp"
|
||||||
#include "ui/game/CGVideoOptions.hpp"
|
#include "console/CVar.hpp"
|
||||||
|
#include "console/Detect.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
|
#include "ui/game/CGVideoOptions.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.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) {
|
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) {
|
int32_t Script_GetCurrentResolution(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
WHOA_UNIMPLEMENTED(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user