mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 10:25:59 +03:00
Merge eeab035664 into f1d1dad08b
This commit is contained in:
commit
ea1acadb11
@ -274,6 +274,7 @@ void ConsoleDeviceInitialize(const char* title) {
|
|||||||
s_requestedFormat.hwTnL = true;
|
s_requestedFormat.hwTnL = true;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
s_requestedFormat.hwCursor = true;
|
||||||
|
|
||||||
CGxFormat format;
|
CGxFormat format;
|
||||||
memcpy(&format, &s_requestedFormat, sizeof(s_requestedFormat));
|
memcpy(&format, &s_requestedFormat, sizeof(s_requestedFormat));
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "console/Command.hpp"
|
#include "console/Command.hpp"
|
||||||
#include "console/Screen.hpp"
|
#include "console/Screen.hpp"
|
||||||
#include "event/Event.hpp"
|
#include "event/Event.hpp"
|
||||||
|
#include "storm/Unicode.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
static int32_t s_historyIndex = 0;
|
static int32_t s_historyIndex = 0;
|
||||||
@ -11,24 +12,20 @@ static int32_t s_historyIndex = 0;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int32_t OnChar(const EVENT_DATA_CHAR* data, void* param) {
|
int32_t OnChar(const EVENT_DATA_CHAR* data, void* param) {
|
||||||
char character[2];
|
char character[8] = {};
|
||||||
|
|
||||||
if (ConsoleAccessGetEnabled() && EventIsKeyDown(ConsoleGetHotKey())) {
|
if (ConsoleAccessGetEnabled() && EventIsKeyDown(ConsoleGetHotKey())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConsoleGetActive()) {
|
if (ConsoleGetActive()) {
|
||||||
character[0] = char(data->ch);
|
SUniSPutUTF8(data->ch, character);
|
||||||
character[1] = 0;
|
|
||||||
|
|
||||||
PasteInInputLine(character);
|
PasteInInputLine(character);
|
||||||
ResetHighlight();
|
ResetHighlight();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SUniSPutUTF8(data->ch, character);
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -539,7 +539,10 @@ int32_t OsWindowProc(void* window, uint32_t message, uintptr_t wparam, intptr_t
|
|||||||
uint32_t character = wparam;
|
uint32_t character = wparam;
|
||||||
|
|
||||||
if (wparam >= 128) {
|
if (wparam >= 128) {
|
||||||
// TODO
|
// Workaround
|
||||||
|
wchar_t u16_character = 0;
|
||||||
|
::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, reinterpret_cast<char*>(&wparam), 1, &u16_character, 1);
|
||||||
|
character = u16_character;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsQueuePut(OS_INPUT_CHAR, character, LOWORD(lparam), 0, 0);
|
OsQueuePut(OS_INPUT_CHAR, character, LOWORD(lparam), 0, 0);
|
||||||
|
|||||||
@ -366,46 +366,48 @@ void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t comp
|
|||||||
FrameScript_SignalEvent(4, "%s", msg);
|
FrameScript_SignalEvent(4, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (complete) {
|
if (!complete) {
|
||||||
if (result == 0) {
|
return;
|
||||||
if (errorCode != 2) {
|
}
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
|
if (errorCode != 2) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
CGlueMgr::m_idleState = IDLE_NONE;
|
||||||
|
CGlueMgr::m_showedDisconnect = 0;
|
||||||
|
|
||||||
|
if (errorCode == 2) {
|
||||||
|
// TODO CGlueMgr::m_disconnectPending = 1;
|
||||||
|
// TODO ClientServices::Connection()->Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode != 13) {
|
||||||
|
// TODO CCharacterSelection::ClearCharacterList();
|
||||||
|
|
||||||
|
if (ClientServices::GetInstance()->m_realmList.Count()) {
|
||||||
|
FrameScript_SignalEvent(5, nullptr);
|
||||||
|
CRealmList::UpdateList();
|
||||||
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
CGlueMgr::m_idleState = IDLE_NONE;
|
|
||||||
CGlueMgr::m_showedDisconnect = 0;
|
|
||||||
|
|
||||||
if (errorCode == 2) {
|
|
||||||
// TODO CGlueMgr::m_disconnectPending = 1;
|
|
||||||
// TODO ClientServices::Connection()->Disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorCode != 13) {
|
|
||||||
// TODO CCharacterSelection::ClearCharacterList();
|
|
||||||
|
|
||||||
if (ClientServices::GetInstance()->m_realmList.Count()) {
|
|
||||||
FrameScript_SignalEvent(5, nullptr);
|
|
||||||
CRealmList::UpdateList();
|
|
||||||
} else {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(CGlueMgr::m_currentScreen, "charselect", STORM_MAX_STR)) {
|
|
||||||
CGlueMgr::SetScreen("login");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == COP_CONNECT) {
|
if (!SStrCmpI(CGlueMgr::m_currentScreen, "charselect", STORM_MAX_STR)) {
|
||||||
// TODO
|
CGlueMgr::SetScreen("login");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (op == COP_CONNECT) {
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -333,7 +333,7 @@ void CGxDevice::ICursorDraw() {
|
|||||||
// Turn off everything
|
// Turn off everything
|
||||||
GxRsSet(GxRs_PolygonOffset, 0);
|
GxRsSet(GxRs_PolygonOffset, 0);
|
||||||
GxRsSet(GxRs_NormalizeNormals, 0);
|
GxRsSet(GxRs_NormalizeNormals, 0);
|
||||||
GxRsSet(GxRs_BlendingMode, 1);
|
GxRsSet(GxRs_BlendingMode, GxBlend_AlphaKey);
|
||||||
GxRsSetAlphaRef();
|
GxRsSetAlphaRef();
|
||||||
GxRsSet(GxRs_Lighting, 0);
|
GxRsSet(GxRs_Lighting, 0);
|
||||||
GxRsSet(GxRs_Fog, 0);
|
GxRsSet(GxRs_Fog, 0);
|
||||||
@ -355,6 +355,9 @@ void CGxDevice::ICursorDraw() {
|
|||||||
float cursorDepth = 1.0f;
|
float cursorDepth = 1.0f;
|
||||||
|
|
||||||
C44Matrix projection;
|
C44Matrix projection;
|
||||||
|
// Workaround for software cursor
|
||||||
|
// C44Matrix projection(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0.002, 0, -1, -1, 0, 1);
|
||||||
|
// this->XformSetProjection(projection);
|
||||||
|
|
||||||
if (!this->StereoEnabled() ||
|
if (!this->StereoEnabled() ||
|
||||||
(CGxDevice::s_uiVertexShader == 0 || !s_uiVertexShader->Valid()) ||
|
(CGxDevice::s_uiVertexShader == 0 || !s_uiVertexShader->Valid()) ||
|
||||||
|
|||||||
@ -334,11 +334,17 @@ 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);
|
||||||
|
} else {
|
||||||
|
// Uncomment when the "glove" cursor will be fixed
|
||||||
|
//break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Uncomment when the "glove" cursor will be fixed
|
||||||
|
//break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -488,8 +494,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;
|
||||||
@ -1102,6 +1107,17 @@ void CGxDeviceD3d::IRsSendToHw(EGxRenderState which) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GxRs_Lighting: {
|
||||||
|
int32_t lightingEnable = 0;
|
||||||
|
|
||||||
|
if (this->MasterEnable(GxMasterEnable_Lighting)) {
|
||||||
|
lightingEnable = static_cast<int32_t>(state->m_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_d3dDevice->SetRenderState(D3DRS_LIGHTING, lightingEnable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GxRs_DepthTest:
|
case GxRs_DepthTest:
|
||||||
case GxRs_DepthFunc: {
|
case GxRs_DepthFunc: {
|
||||||
auto depthTest = static_cast<uint32_t>((&this->m_appRenderStates[GxRs_DepthTest])->m_value);
|
auto depthTest = static_cast<uint32_t>((&this->m_appRenderStates[GxRs_DepthTest])->m_value);
|
||||||
@ -1249,6 +1265,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();
|
||||||
|
|||||||
@ -1578,7 +1578,7 @@ GLTexture* GLSDLDevice::CreateTextureCubeMap(uint32_t size, uint32_t numMipMap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GLSDLDevice::Draw(GLEnum primitive, uint32_t a3, uint32_t a4) {
|
void GLSDLDevice::Draw(GLEnum primitive, uint32_t a3, uint32_t a4) {
|
||||||
// TODO
|
this->GLSDLDraw(primitive, a3, a3 + a4, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLSDLDevice::DrawIndexed(GLEnum primitive, uint32_t a3, uint32_t a4, uint32_t a5, uint32_t a6, uint32_t count) {
|
void GLSDLDevice::DrawIndexed(GLEnum primitive, uint32_t a3, uint32_t a4, uint32_t a5, uint32_t a6, uint32_t count) {
|
||||||
|
|||||||
@ -110,7 +110,7 @@ int32_t RealmConnection::HandleAuthChallenge(AuthenticationChallenge* challenge)
|
|||||||
// TODO switch to WDataStore
|
// TODO switch to WDataStore
|
||||||
CDataStore msg;
|
CDataStore msg;
|
||||||
|
|
||||||
uint32_t localChallenge;
|
uint32_t localChallenge = 0;
|
||||||
|
|
||||||
msg.Put(static_cast<uint32_t>(CMSG_AUTH_SESSION));
|
msg.Put(static_cast<uint32_t>(CMSG_AUTH_SESSION));
|
||||||
|
|
||||||
|
|||||||
@ -152,6 +152,13 @@ void CBackdropGenerator::LoadXML(XMLNode* node, CStatus* status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBackdropGenerator::SetVertexColor(const CImVector& color) {
|
||||||
|
this->m_color = color;
|
||||||
|
if (this->m_backgroundTexture) {
|
||||||
|
this->m_backgroundTexture->SetVertexColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CBackdropGenerator::SetBorderVertexColor(const CImVector& borderColor) {
|
void CBackdropGenerator::SetBorderVertexColor(const CImVector& borderColor) {
|
||||||
this->m_borderColor = borderColor;
|
this->m_borderColor = borderColor;
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ class CBackdropGenerator {
|
|||||||
CBackdropGenerator();
|
CBackdropGenerator();
|
||||||
void Generate(const CRect* rect);
|
void Generate(const CRect* rect);
|
||||||
void LoadXML(XMLNode* node, CStatus* status);
|
void LoadXML(XMLNode* node, CStatus* status);
|
||||||
|
void SetVertexColor(const CImVector& color);
|
||||||
void SetBorderVertexColor(const CImVector& borderColor);
|
void SetBorderVertexColor(const CImVector& borderColor);
|
||||||
void SetOutput(CSimpleFrame* frame);
|
void SetOutput(CSimpleFrame* frame);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -871,6 +871,11 @@ int32_t CSimpleEditBox::OnLayerKeyDown(const CKeyEvent& evt) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case KEY_TAB: {
|
||||||
|
// TODO correct implementation
|
||||||
|
this->RunOnTabPressedScript();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - remaining keys
|
// - remaining keys
|
||||||
|
|
||||||
@ -994,6 +999,12 @@ void CSimpleEditBox::RunOnEnterPressedScript() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleEditBox::RunOnTabPressedScript() {
|
||||||
|
if (this->m_onTabPressed.luaRef) {
|
||||||
|
this->RunScript(this->m_onTabPressed, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|||||||
@ -98,6 +98,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);
|
||||||
|
|||||||
@ -176,11 +176,34 @@ int32_t CSimpleEditBox_GetTextInsets(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleEditBox_SetFocus(lua_State* L) {
|
int32_t CSimpleEditBox_SetFocus(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
luaL_error(L, "Attempt to find 'this' in non-table object (used '.' instead of ':' ?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_rawgeti(L, 1, 0);
|
||||||
|
auto object = reinterpret_cast<CSimpleEditBox*>(lua_touserdata(L, -1));
|
||||||
|
lua_settop(L, -2);
|
||||||
|
|
||||||
|
STORM_ASSERT(object);
|
||||||
|
|
||||||
|
CSimpleEditBox::SetKeyboardFocus(object);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleEditBox_ClearFocus(lua_State* L) {
|
int32_t CSimpleEditBox_ClearFocus(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
luaL_error(L, "Attempt to find 'this' in non-table object (used '.' instead of ':' ?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_rawgeti(L, 1, 0);
|
||||||
|
auto object = reinterpret_cast<CSimpleEditBox*>(lua_touserdata(L, -1));
|
||||||
|
lua_settop(L, -2);
|
||||||
|
|
||||||
|
STORM_ASSERT(object);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// CSimpleEditBox::ClearKeyboardFocus(object);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleEditBox_HasFocus(lua_State* L) {
|
int32_t CSimpleEditBox_HasFocus(lua_State* L) {
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
int32_t CSimpleFontString_IsObjectType(lua_State* L) {
|
int32_t CSimpleFontString_IsObjectType(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
WHOA_UNIMPLEMENTED(0);
|
||||||
@ -132,7 +134,24 @@ int32_t CSimpleFontString_SetText(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_SetFormattedText(lua_State* L) {
|
int32_t CSimpleFontString_SetFormattedText(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
luaL_error(L, "Attempt to find 'this' in non-table object (used '.' instead of ':' ?)");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto type = CSimpleFontString::GetObjectType();
|
||||||
|
auto string = static_cast<CSimpleFontString*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
if (!string->m_font) {
|
||||||
|
luaL_error(L, "%s:SetText(): Font not set", string->GetDisplayName());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char text[2048] = {};
|
||||||
|
FrameScript_Sprintf(L, 2, text, sizeof(text));
|
||||||
|
string->SetText(text, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_GetTextColor(lua_State* L) {
|
int32_t CSimpleFontString_GetTextColor(lua_State* L) {
|
||||||
|
|||||||
@ -1327,7 +1327,19 @@ void CSimpleFrame::SetBeingScrolled(int32_t a2, int32_t a3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::SetFrameAlpha(uint8_t alpha) {
|
void CSimpleFrame::SetFrameAlpha(uint8_t alpha) {
|
||||||
// TODO
|
if (this->m_alpha == alpha) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_alpha = alpha;
|
||||||
|
|
||||||
|
for (auto region = this->m_regions.Head(); region; region = this->m_regions.Link(region)->Next()) {
|
||||||
|
region->OnColorChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto child = this->m_children.Head(); child; child = this->m_children.Link(child)->Next()) {
|
||||||
|
child->frame->SetFrameAlpha(alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::SetFrameFlag(int32_t flag, int32_t on) {
|
void CSimpleFrame::SetFrameFlag(int32_t flag, int32_t on) {
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
float m_depth = 0.0;
|
float m_depth = 0.0;
|
||||||
FRAME_STRATA m_strata = FRAME_STRATA_MEDIUM;
|
FRAME_STRATA m_strata = FRAME_STRATA_MEDIUM;
|
||||||
int32_t m_level = 0;
|
int32_t m_level = 0;
|
||||||
|
uint8_t m_alpha = 255;
|
||||||
uint32_t m_eventmask = 0;
|
uint32_t m_eventmask = 0;
|
||||||
int32_t m_shown = 0;
|
int32_t m_shown = 0;
|
||||||
int32_t m_visible = 0;
|
int32_t m_visible = 0;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "ui/CSimpleFrame.hpp"
|
#include "ui/CSimpleFrame.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
|
#include "ui/CBackdropGenerator.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -460,7 +461,28 @@ int32_t CSimpleFrame_GetBackdropColor(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetBackdropColor(lua_State* L) {
|
int32_t CSimpleFrame_SetBackdropColor(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
luaL_error(L, "Attempt to find 'this' in non-table object (used '.' instead of ':' ?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_rawgeti(L, 1, 0);
|
||||||
|
auto object = reinterpret_cast<CSimpleFrame*>(lua_touserdata(L, -1));
|
||||||
|
lua_settop(L, -2);
|
||||||
|
|
||||||
|
STORM_ASSERT(object);
|
||||||
|
|
||||||
|
CImVector color;
|
||||||
|
auto red = lua_tonumber(L, 2);
|
||||||
|
auto green = lua_tonumber(L, 3);
|
||||||
|
auto blue = lua_tonumber(L, 4);
|
||||||
|
auto alpha = lua_isnumber(L, 5) ? lua_tonumber(L, 5) : 1.0;
|
||||||
|
color.Set(alpha, red, green, blue);
|
||||||
|
|
||||||
|
if (object->m_backdrop) {
|
||||||
|
object->m_backdrop->SetVertexColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
||||||
@ -468,7 +490,28 @@ int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetBackdropBorderColor(lua_State* L) {
|
int32_t CSimpleFrame_SetBackdropBorderColor(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
luaL_error(L, "Attempt to find 'this' in non-table object (used '.' instead of ':' ?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_rawgeti(L, 1, 0);
|
||||||
|
auto object = reinterpret_cast<CSimpleFrame*>(lua_touserdata(L, -1));
|
||||||
|
lua_settop(L, -2);
|
||||||
|
|
||||||
|
STORM_ASSERT(object);
|
||||||
|
|
||||||
|
CImVector color;
|
||||||
|
auto red = lua_tonumber(L, 2);
|
||||||
|
auto green = lua_tonumber(L, 3);
|
||||||
|
auto blue = lua_tonumber(L, 4);
|
||||||
|
auto alpha = lua_isnumber(L, 5) ? lua_tonumber(L, 5) : 1.0;
|
||||||
|
color.Set(alpha, red, green, blue);
|
||||||
|
|
||||||
|
if (object->m_backdrop) {
|
||||||
|
object->m_backdrop->SetBorderVertexColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetDepth(lua_State* L) {
|
int32_t CSimpleFrame_SetDepth(lua_State* L) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include <storm/Array.hpp>
|
#include <storm/Array.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
#include <tempest/Vector.hpp>
|
#include <tempest/Vector.hpp>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
const char* g_glueScriptEvents[41];
|
const char* g_glueScriptEvents[41];
|
||||||
const char* g_scriptEvents[722];
|
const char* g_scriptEvents[722];
|
||||||
@ -867,6 +868,216 @@ void FrameScript_UnregisterScriptEvent(FrameScript_Object* object, FrameScript_E
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void addchar(char* buffer, size_t bufferSize, char ch) {
|
||||||
|
auto length = SStrLen(buffer);
|
||||||
|
if (length + 1 < bufferSize)
|
||||||
|
{
|
||||||
|
buffer[length++] = ch;
|
||||||
|
buffer[length] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addstring(char* buffer, size_t bufferSize, const char* source) {
|
||||||
|
uint32_t dsize = 0;
|
||||||
|
uint32_t size = 0;
|
||||||
|
|
||||||
|
dsize = SStrLen(buffer);
|
||||||
|
size = SStrLen(source);
|
||||||
|
|
||||||
|
if (dsize + size >= bufferSize) {
|
||||||
|
size = bufferSize - dsize;
|
||||||
|
// Check for space for trailing zero
|
||||||
|
if (size < 2) {
|
||||||
|
size = 0;
|
||||||
|
} else {
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
memmove(&buffer[dsize], source, size);
|
||||||
|
|
||||||
|
buffer[dsize + size] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addstring(char* buffer, size_t bufferSize, const char* source, size_t count) {
|
||||||
|
uint32_t dsize = 0;
|
||||||
|
uint32_t size = 0;
|
||||||
|
|
||||||
|
dsize = SStrLen(buffer);
|
||||||
|
size = std::min(SStrLen(source), count);
|
||||||
|
|
||||||
|
if (dsize + size >= bufferSize) {
|
||||||
|
size = bufferSize - dsize;
|
||||||
|
// Check for space for trailing zero
|
||||||
|
if (size < 2) {
|
||||||
|
size = 0;
|
||||||
|
} else {
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
memmove(&buffer[dsize], source, size);
|
||||||
|
|
||||||
|
buffer[dsize + size] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addquoted(lua_State* L, char* buffer, size_t bufferSize, int arg) {
|
||||||
|
size_t l;
|
||||||
|
const char* s = luaL_checklstring(L, arg, &l);
|
||||||
|
addchar(buffer, bufferSize, '"');
|
||||||
|
while (l--) {
|
||||||
|
switch (*s) {
|
||||||
|
case '"':
|
||||||
|
case '\\':
|
||||||
|
case '\n': {
|
||||||
|
addchar(buffer, bufferSize, '\\');
|
||||||
|
addchar(buffer, bufferSize, *s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '\r': {
|
||||||
|
addstring(buffer, bufferSize, "\\r");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '\0': {
|
||||||
|
addstring(buffer, bufferSize, "\\000");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
addchar(buffer, bufferSize, *s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
addchar(buffer, bufferSize, '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FORMAT_FLAGS "-+ #0"
|
||||||
|
|
||||||
|
static const char* scanformat(lua_State* L, const char* strfrmt, char* form) {
|
||||||
|
const char* flags = "-+ #0";
|
||||||
|
const char* p = strfrmt;
|
||||||
|
|
||||||
|
while (*p != '\0' && SStrChrR(FORMAT_FLAGS, *p) != NULL) {
|
||||||
|
p++; /* skip flags */
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((size_t)(p - strfrmt) >= sizeof(FORMAT_FLAGS)) {
|
||||||
|
luaL_error(L, "invalid format (repeated flags)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isdigit((unsigned char)(*p))) {
|
||||||
|
p++; /* skip width */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isdigit((unsigned char)(*p))) {
|
||||||
|
p++; /* (2 digits at most) */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p == '.') {
|
||||||
|
p++;
|
||||||
|
if (isdigit((unsigned char)(*p))) {
|
||||||
|
p++; /* skip precision */
|
||||||
|
}
|
||||||
|
if (isdigit((unsigned char)(*p))) {
|
||||||
|
p++; /* (2 digits at most) */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isdigit((unsigned char)(*p))) {
|
||||||
|
luaL_error(L, "invalid format (width or precision too long)");
|
||||||
|
}
|
||||||
|
|
||||||
|
*(form++) = '%';
|
||||||
|
strncpy(form, strfrmt, p - strfrmt + 1);
|
||||||
|
form += p - strfrmt + 1;
|
||||||
|
*form = '\0';
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addintlen(char* form) {
|
||||||
|
size_t l = SStrLen(form);
|
||||||
|
char spec = form[l - 1];
|
||||||
|
strcpy(form + l - 1, LUA_INTFRMLEN);
|
||||||
|
form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
|
||||||
|
form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameScript_Sprintf(lua_State* L, int startIndex, char* buffer, uint32_t bufferSize) {
|
||||||
|
// maximum size of each formatted item (> len(format('%99.99f', -1e308)))
|
||||||
|
const size_t MAX_ITEM = 512;
|
||||||
|
|
||||||
|
// maximum size of each format specification (such as '%-099.99d')
|
||||||
|
// (+10 accounts for %99.99x plus margin of error)
|
||||||
|
const size_t MAX_FORMAT = sizeof(FORMAT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10;
|
||||||
|
|
||||||
|
int arg = startIndex;
|
||||||
|
size_t sfl;
|
||||||
|
const char* strfrmt = luaL_checklstring(L, arg, &sfl);
|
||||||
|
const char* strfrmt_end = strfrmt + sfl;
|
||||||
|
while (strfrmt < strfrmt_end) {
|
||||||
|
if (*strfrmt != '%') {
|
||||||
|
addchar(buffer, bufferSize, *strfrmt++);
|
||||||
|
} else if (*++strfrmt == '%') {
|
||||||
|
addchar(buffer, bufferSize, *strfrmt++); /* %% */
|
||||||
|
} else { /* format item */
|
||||||
|
char form[MAX_FORMAT]; /* to store the format (`%...') */
|
||||||
|
char buff[MAX_ITEM]; /* to store the formatted item */
|
||||||
|
arg++;
|
||||||
|
strfrmt = scanformat(L, strfrmt, form);
|
||||||
|
switch (*strfrmt++) {
|
||||||
|
case 'c': {
|
||||||
|
sprintf(buff, form, (int)luaL_checknumber(L, arg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'd':
|
||||||
|
case 'i': {
|
||||||
|
addintlen(form);
|
||||||
|
sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'o':
|
||||||
|
case 'u':
|
||||||
|
case 'x':
|
||||||
|
case 'X': {
|
||||||
|
addintlen(form);
|
||||||
|
sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'e':
|
||||||
|
case 'E':
|
||||||
|
case 'f':
|
||||||
|
case 'g':
|
||||||
|
case 'G': {
|
||||||
|
sprintf(buff, form, (double)luaL_checknumber(L, arg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'q': {
|
||||||
|
addquoted(L, buffer, bufferSize, arg);
|
||||||
|
continue; /* skip the 'addsize' at the end */
|
||||||
|
}
|
||||||
|
case 's': {
|
||||||
|
size_t l;
|
||||||
|
const char* s = luaL_checklstring(L, arg, &l);
|
||||||
|
if (!strchr(form, '.') && l >= 100) {
|
||||||
|
/* no precision and string is too long to be formatted;
|
||||||
|
keep original string */
|
||||||
|
continue; /* skip the `addsize' at the end */
|
||||||
|
} else {
|
||||||
|
sprintf(buff, form, s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: { /* also treat cases `pnLlh' */
|
||||||
|
luaL_error(L, "invalid option " LUA_QL("%%%c") " to " LUA_QL("format"), *(strfrmt - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addstring(buffer, bufferSize, buff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GlueScriptEventsInitialize() {
|
void GlueScriptEventsInitialize() {
|
||||||
g_glueScriptEvents[0] = "SET_GLUE_SCREEN";
|
g_glueScriptEvents[0] = "SET_GLUE_SCREEN";
|
||||||
g_glueScriptEvents[1] = "START_GLUE_MUSIC";
|
g_glueScriptEvents[1] = "START_GLUE_MUSIC";
|
||||||
|
|||||||
@ -100,6 +100,8 @@ void FrameScript_SignalEvent(uint32_t index, const char* format, ...);
|
|||||||
|
|
||||||
void FrameScript_UnregisterScriptEvent(FrameScript_Object* object, FrameScript_EventObject* event);
|
void FrameScript_UnregisterScriptEvent(FrameScript_Object* object, FrameScript_EventObject* event);
|
||||||
|
|
||||||
|
void FrameScript_Sprintf(lua_State* L, int startIndex, char* buffer, uint32_t bufferSize);
|
||||||
|
|
||||||
void GlueScriptEventsInitialize();
|
void GlueScriptEventsInitialize();
|
||||||
|
|
||||||
void ScriptEventsInitialize();
|
void ScriptEventsInitialize();
|
||||||
|
|||||||
@ -19,7 +19,15 @@ int32_t Script_IsShiftKeyDown(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetBuildInfo(lua_State* L) {
|
int32_t Script_GetBuildInfo(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto szVersion = FrameScript_GetText("VERSION", -1, GENDER_NOT_APPLICABLE);
|
||||||
|
auto szVersionType = FrameScript_GetText("RELEASE_BUILD", -1, GENDER_NOT_APPLICABLE);
|
||||||
|
|
||||||
|
lua_pushstring(L, szVersion);
|
||||||
|
lua_pushstring(L, szVersionType);
|
||||||
|
lua_pushstring(L, "3.3.5");
|
||||||
|
lua_pushstring(L, "12340");
|
||||||
|
lua_pushstring(L, "Jun 24 2010");
|
||||||
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetLocale(lua_State* L) {
|
int32_t Script_GetLocale(lua_State* L) {
|
||||||
@ -27,7 +35,9 @@ int32_t Script_GetLocale(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetSavedAccountName(lua_State* L) {
|
int32_t Script_GetSavedAccountName(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
// TODO
|
||||||
|
lua_pushstring(L, "");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSavedAccountName(lua_State* L) {
|
int32_t Script_SetSavedAccountName(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user