mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-07-25 18:05:49 +03:00
Compare commits
3 Commits
f039d4f88c
...
d80e2b4b4f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d80e2b4b4f | ||
![]() |
c4a516c44d | ||
![]() |
6030a75530 |
@ -334,7 +334,7 @@ LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
case WM_SETCURSOR: {
|
case WM_SETCURSOR: {
|
||||||
if (device) {
|
if (device) {
|
||||||
if (device->m_d3dDevice && lParam == 1) {
|
if (device->m_d3dDevice && LOWORD(lParam) == HTCLIENT) {
|
||||||
SetCursor(nullptr);
|
SetCursor(nullptr);
|
||||||
BOOL show = device->m_cursorVisible && device->m_hardwareCursor ? TRUE : FALSE;
|
BOOL show = device->m_cursorVisible && device->m_hardwareCursor ? TRUE : FALSE;
|
||||||
device->m_d3dDevice->ShowCursor(show);
|
device->m_d3dDevice->ShowCursor(show);
|
||||||
@ -474,7 +474,7 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
|
|||||||
ShowWindow(this->m_hwnd, 0);
|
ShowWindow(this->m_hwnd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
this->IDestroyD3dDevice();
|
||||||
|
|
||||||
if (this->m_hwnd) {
|
if (this->m_hwnd) {
|
||||||
DestroyWindow(this->m_hwnd);
|
DestroyWindow(this->m_hwnd);
|
||||||
@ -488,8 +488,7 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
|
|||||||
|
|
||||||
if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) {
|
if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) {
|
||||||
this->intF64 = 1;
|
this->intF64 = 1;
|
||||||
|
this->m_hwCursorNeedsUpdate = 1;
|
||||||
// TODO
|
|
||||||
|
|
||||||
if (this->m_format.window == 0) {
|
if (this->m_format.window == 0) {
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
@ -498,6 +497,14 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
CGxDevice::Log("CGxDeviceD3d::DeviceSetFormat(): unable to set format!");
|
||||||
|
this->IDestroyD3dDevice();
|
||||||
|
if (this->m_hwnd) {
|
||||||
|
DestroyWindow(this->m_hwnd);
|
||||||
|
}
|
||||||
|
this->m_hwnd = nullptr;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,6 +1256,11 @@ void CGxDeviceD3d::CursorSetVisible(int32_t visible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGxDeviceD3d::CursorUnlock(uint32_t x, uint32_t y) {
|
||||||
|
CGxDevice::CursorUnlock(x, y);
|
||||||
|
this->m_hwCursorNeedsUpdate = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void CGxDeviceD3d::ICursorDraw() {
|
void CGxDeviceD3d::ICursorDraw() {
|
||||||
if (!this->m_hardwareCursor) {
|
if (!this->m_hardwareCursor) {
|
||||||
this->ISceneBegin();
|
this->ISceneBegin();
|
||||||
|
@ -252,6 +252,7 @@ class CGxDeviceD3d : public CGxDevice {
|
|||||||
virtual void ICursorDestroy();
|
virtual void ICursorDestroy();
|
||||||
virtual void ICursorDraw();
|
virtual void ICursorDraw();
|
||||||
virtual void CursorSetVisible(int32_t visible);
|
virtual void CursorSetVisible(int32_t visible);
|
||||||
|
virtual void CursorUnlock(uint32_t x, uint32_t y);
|
||||||
virtual int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format);
|
virtual int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format);
|
||||||
virtual int32_t DeviceSetFormat(const CGxFormat& format);
|
virtual int32_t DeviceSetFormat(const CGxFormat& format);
|
||||||
virtual void* DeviceWindow();
|
virtual void* DeviceWindow();
|
||||||
|
@ -878,6 +878,11 @@ int32_t CSimpleEditBox::OnLayerKeyDown(const CKeyEvent& evt) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case KEY_TAB: {
|
||||||
|
this->RunOnTabPressedScript();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - remaining keys
|
// - remaining keys
|
||||||
|
|
||||||
@ -1001,6 +1006,13 @@ void CSimpleEditBox::RunOnEnterPressedScript() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleEditBox::RunOnTabPressedScript() {
|
||||||
|
if (this->m_onTabPressed.luaRef) {
|
||||||
|
this->RunScript(this->m_onTabPressed, 0, 0);
|
||||||
|
}
|
||||||
|
// TODO: virtual call of CSimpleEditBox::DispatchAction ?
|
||||||
|
}
|
||||||
|
|
||||||
void CSimpleEditBox::RunOnTextChangedScript(int32_t changed) {
|
void CSimpleEditBox::RunOnTextChangedScript(int32_t changed) {
|
||||||
if (this->m_onTextChanged.luaRef) {
|
if (this->m_onTextChanged.luaRef) {
|
||||||
auto L = FrameScript_GetContext();
|
auto L = FrameScript_GetContext();
|
||||||
|
@ -99,6 +99,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
|
|||||||
void RunOnEditFocusGainedScript();
|
void RunOnEditFocusGainedScript();
|
||||||
void RunOnEditFocusLostScript();
|
void RunOnEditFocusLostScript();
|
||||||
void RunOnEnterPressedScript();
|
void RunOnEnterPressedScript();
|
||||||
|
void RunOnTabPressedScript();
|
||||||
void RunOnTextChangedScript(int32_t changed);
|
void RunOnTextChangedScript(int32_t changed);
|
||||||
void SetCursorPosition(int32_t position);
|
void SetCursorPosition(int32_t position);
|
||||||
void SetHistoryLines(int32_t a2);
|
void SetHistoryLines(int32_t a2);
|
||||||
|
@ -139,8 +139,8 @@ int32_t CSimpleFontString_SetFormattedText(lua_State* L) {
|
|||||||
luaL_error(L, "%s:SetFormattedText(): Font not set", string->GetDisplayName());
|
luaL_error(L, "%s:SetFormattedText(): Font not set", string->GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[4096] = {};
|
char buffer[4096];
|
||||||
char* text = FrameScript_Sprintf(L, 2, buffer, sizeof(buffer));
|
auto text = FrameScript_Sprintf(L, 2, buffer, sizeof(buffer));
|
||||||
string->SetText(text, 1);
|
string->SetText(text, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "ui/FrameScriptInternal.hpp"
|
#include "ui/FrameScriptInternal.hpp"
|
||||||
#include "ui/FrameScript_Object.hpp"
|
#include "ui/FrameScript_Object.hpp"
|
||||||
#include "ui/LuaMemory.hpp"
|
#include "ui/LuaMemory.hpp"
|
||||||
|
#include "ui/LuaExtraFuncs.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/SFile.hpp"
|
#include "util/SFile.hpp"
|
||||||
@ -451,26 +452,24 @@ void FrameScript_GetColor(lua_State* L, int32_t idx, CImVector& color) {
|
|||||||
color.Set(a, r, g, b);
|
color.Set(a, r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SetDecimalConversion(int32_t enabled) {
|
||||||
|
return lua_setdecimalconversion(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
lua_State* FrameScript_GetContext(void) {
|
lua_State* FrameScript_GetContext(void) {
|
||||||
return FrameScript::s_context;
|
return FrameScript::s_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* FrameScript_Sprintf(lua_State* L, int32_t idx, char* buffer, uint32_t size) {
|
const char* FrameScript_Sprintf(lua_State* L, int32_t idx, char* buffer, uint32_t size) {
|
||||||
size_t formatLength = 0;
|
size_t formatLength = 0;
|
||||||
const char* format = luaL_checklstring(L, idx, &formatLength);
|
const char* format = luaL_checklstring(L, idx, &formatLength);
|
||||||
const char* formatEnd = format + formatLength;
|
const char* formatEnd = format + formatLength;
|
||||||
|
|
||||||
char* result = buffer;
|
char* result = buffer;
|
||||||
|
|
||||||
if (format >= formatEnd) {
|
|
||||||
*buffer = '\0';
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t currentIndex = idx;
|
int32_t currentIndex = idx;
|
||||||
|
|
||||||
while (size > 1) {
|
while (format < formatEnd && size > 1) {
|
||||||
char character = *format++;
|
char character = *format++;
|
||||||
if (character == '%') {
|
if (character == '%') {
|
||||||
char argument = *format;
|
char argument = *format;
|
||||||
@ -552,7 +551,7 @@ char* FrameScript_Sprintf(lua_State* L, int32_t idx, char* buffer, uint32_t size
|
|||||||
double number = luaL_checknumber(L, currentIndex);
|
double number = luaL_checknumber(L, currentIndex);
|
||||||
size_t length = SStrPrintf(buffer, size, subformat, number);
|
size_t length = SStrPrintf(buffer, size, subformat, number);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
// TODO: lua_convertdecimal(buffer)
|
lua_convertdecimal(buffer);
|
||||||
buffer += length;
|
buffer += length;
|
||||||
size -= length;
|
size -= length;
|
||||||
}
|
}
|
||||||
@ -584,7 +583,7 @@ char* FrameScript_Sprintf(lua_State* L, int32_t idx, char* buffer, uint32_t size
|
|||||||
auto number = static_cast<int32_t>(luaL_checknumber(L, currentIndex));
|
auto number = static_cast<int32_t>(luaL_checknumber(L, currentIndex));
|
||||||
size_t length = SStrPrintf(buffer, size, subformat, number);
|
size_t length = SStrPrintf(buffer, size, subformat, number);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
// TODO: lua_convertdecimal(buffer)
|
lua_convertdecimal(buffer);
|
||||||
buffer += length;
|
buffer += length;
|
||||||
size -= length;
|
size -= length;
|
||||||
}
|
}
|
||||||
@ -612,10 +611,6 @@ char* FrameScript_Sprintf(lua_State* L, int32_t idx, char* buffer, uint32_t size
|
|||||||
*buffer++ = character;
|
*buffer++ = character;
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format >= formatEnd) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
|
@ -78,9 +78,11 @@ void FrameScript_Flush();
|
|||||||
|
|
||||||
void FrameScript_GetColor(lua_State* L, int32_t idx, CImVector& color);
|
void FrameScript_GetColor(lua_State* L, int32_t idx, CImVector& color);
|
||||||
|
|
||||||
|
int32_t SetDecimalConversion(int32_t enabled);
|
||||||
|
|
||||||
lua_State* FrameScript_GetContext();
|
lua_State* FrameScript_GetContext();
|
||||||
|
|
||||||
char* FrameScript_Sprintf(lua_State * L, int32_t idx, char* buffer, uint32_t size);
|
const char* FrameScript_Sprintf(lua_State * L, int32_t idx, char* buffer, uint32_t size);
|
||||||
|
|
||||||
const char* FrameScript_GetCurrentObject(lua_State* L, int32_t a2);
|
const char* FrameScript_GetCurrentObject(lua_State* L, int32_t a2);
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
|
static bool s_luaDecimalConversion = false;
|
||||||
|
|
||||||
|
|
||||||
luaL_Reg FrameScriptInternal::extra_funcs[31] = {
|
luaL_Reg FrameScriptInternal::extra_funcs[31] = {
|
||||||
{ "setglobal", &sub_8168D0 },
|
{ "setglobal", &sub_8168D0 },
|
||||||
{ "getglobal", &sub_816910 },
|
{ "getglobal", &sub_816910 },
|
||||||
@ -169,3 +173,53 @@ int32_t debuglocals(lua_State* L) {
|
|||||||
int32_t scrub(lua_State* L) {
|
int32_t scrub(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
WHOA_UNIMPLEMENTED(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t lua_setdecimalconversion(int32_t enabled) {
|
||||||
|
s_luaDecimalConversion = (enabled != 0);
|
||||||
|
return static_cast<int32_t>(s_luaDecimalConversion);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_convertdecimal(char* string) {
|
||||||
|
if (!s_luaDecimalConversion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t length = SStrLen(string);
|
||||||
|
if (!length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* end = &string[length];
|
||||||
|
while (string < end) {
|
||||||
|
if (*string < '0' || *string > '9') {
|
||||||
|
++string;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char ch;
|
||||||
|
while (true) {
|
||||||
|
ch = *string;
|
||||||
|
|
||||||
|
if ((ch < '0' || ch > '9') && ch != '.') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == ',') {
|
||||||
|
LABEL_13:
|
||||||
|
if (string[1] >= '0' && string[1] <= '9') {
|
||||||
|
*string = '.';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ch == '.' && (string[1] < '0' || string[1] > '9')) {
|
||||||
|
*string = ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++string;
|
||||||
|
}
|
||||||
|
if (ch == ',') {
|
||||||
|
goto LABEL_13;
|
||||||
|
}
|
||||||
|
|
||||||
|
++string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -36,4 +36,7 @@ int32_t debugstack(lua_State*);
|
|||||||
int32_t debuglocals(lua_State*);
|
int32_t debuglocals(lua_State*);
|
||||||
int32_t scrub(lua_State*);
|
int32_t scrub(lua_State*);
|
||||||
|
|
||||||
|
int32_t lua_setdecimalconversion(int32_t enabled);
|
||||||
|
void lua_convertdecimal(char* string);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user