mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-19 14:11:06 +03:00
Compare commits
No commits in common. "856bb72e1a0051599ab93dfcb4365769e9dab287" and "d9b6647c42e6715f60e4de9d1fa0dbc1666072a5" have entirely different histories.
856bb72e1a
...
d9b6647c42
@ -1,11 +1,6 @@
|
|||||||
#include "ui/simple/CSimpleStatusBar.hpp"
|
#include "ui/simple/CSimpleStatusBar.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
|
||||||
#include "ui/simple/CSimpleStatusBarScript.hpp"
|
#include "ui/simple/CSimpleStatusBarScript.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
|
||||||
#include "util/CStatus.hpp"
|
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
|
||||||
|
|
||||||
int32_t CSimpleStatusBar::s_metatable;
|
int32_t CSimpleStatusBar::s_metatable;
|
||||||
int32_t CSimpleStatusBar::s_objectType;
|
int32_t CSimpleStatusBar::s_objectType;
|
||||||
@ -28,6 +23,10 @@ void CSimpleStatusBar::RegisterScriptMethods(lua_State* L) {
|
|||||||
FrameScript_Object::FillScriptMethodTable(L, SimpleStatusBarMethods, NUM_SIMPLE_STATUS_BAR_SCRIPT_METHODS);
|
FrameScript_Object::FillScriptMethodTable(L, SimpleStatusBarMethods, NUM_SIMPLE_STATUS_BAR_SCRIPT_METHODS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimpleStatusBar::CSimpleStatusBar(CSimpleFrame* parent) : CSimpleFrame(parent) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name, ScriptData& data) {
|
FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name, ScriptData& data) {
|
||||||
auto script = this->CSimpleFrame::GetScriptByName(name, data);
|
auto script = this->CSimpleFrame::GetScriptByName(name, data);
|
||||||
|
|
||||||
@ -50,14 +49,6 @@ int32_t CSimpleStatusBar::GetScriptMetaTable() {
|
|||||||
return CSimpleStatusBar::s_metatable;
|
return CSimpleStatusBar::s_metatable;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSimpleStatusBar::GetMaxValue() const {
|
|
||||||
return this->m_maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CSimpleStatusBar::GetMinValue() const {
|
|
||||||
return this->m_minValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CSimpleStatusBar::GetValue() const {
|
float CSimpleStatusBar::GetValue() const {
|
||||||
return this->m_value;
|
return this->m_value;
|
||||||
}
|
}
|
||||||
@ -69,66 +60,6 @@ bool CSimpleStatusBar::IsA(int32_t type) {
|
|||||||
|| type == CScriptObject::s_objectType;
|
|| type == CScriptObject::s_objectType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleStatusBar::LoadXML(const XMLNode* node, CStatus* status) {
|
|
||||||
this->CSimpleFrame::LoadXML(node, status);
|
|
||||||
|
|
||||||
int32_t drawlayer = DRAWLAYER_ARTWORK;
|
|
||||||
auto drawlayerAttr = node->GetAttributeByName("drawLayer");
|
|
||||||
if (drawlayerAttr && *drawlayerAttr) {
|
|
||||||
StringToDrawLayer(drawlayerAttr, drawlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto child = node->GetChild(); child; child = child->GetSibling()) {
|
|
||||||
if (!SStrCmpI(child->GetName(), "BarTexture")) {
|
|
||||||
auto texture = LoadXML_Texture(child, this, status);
|
|
||||||
this->SetBarTexture(texture, drawlayer);
|
|
||||||
} else if (!SStrCmpI(child->GetName(), "BarColor")) {
|
|
||||||
CImVector color = {};
|
|
||||||
LoadXML_Color(child, color);
|
|
||||||
this->SetStatusBarColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto minValueAttr = node->GetAttributeByName("minValue");
|
|
||||||
if (minValueAttr && *minValueAttr) {
|
|
||||||
auto maxValueAttr = node->GetAttributeByName("maxValue");
|
|
||||||
if (maxValueAttr && *maxValueAttr) {
|
|
||||||
auto minValue = SStrToFloat(minValueAttr);
|
|
||||||
auto maxValue = SStrToFloat(maxValueAttr);
|
|
||||||
|
|
||||||
if (minValue < -1.0e12 || minValue > 1.0e12 || maxValue < -1.0e12 || maxValue > 1.0e12) {
|
|
||||||
status->Add(STATUS_ERROR, "Frame %s: Min or Max out of range", this->GetDisplayName());
|
|
||||||
} else if (maxValue - minValue > 1.0e12) {
|
|
||||||
status->Add(STATUS_ERROR, "Frame %s: Min and Max too far apart", this->GetDisplayName());
|
|
||||||
} else {
|
|
||||||
this->SetMinMaxValues(minValue, maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto defaultValueAttr = node->GetAttributeByName("defaultValue");
|
|
||||||
if (defaultValueAttr && *defaultValueAttr) {
|
|
||||||
auto defaultValue = SStrToFloat(defaultValueAttr);
|
|
||||||
this->SetValue(defaultValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto orientationAttr = node->GetAttributeByName("orientation");
|
|
||||||
if (orientationAttr && *orientationAttr) {
|
|
||||||
ORIENTATION orientation;
|
|
||||||
if (StringToOrientation(orientationAttr, orientation)) {
|
|
||||||
this->SetOrientation(orientation);
|
|
||||||
} else {
|
|
||||||
status->Add(STATUS_WARNING, "Frame %s: Unknown orientation %s in element %s", this->GetDisplayName(), orientationAttr, node->GetName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto rotatesTextureAttr = node->GetAttributeByName("rotatesTexture");
|
|
||||||
if (rotatesTextureAttr && *rotatesTextureAttr) {
|
|
||||||
auto rotatesTexture = StringToBOOL(rotatesTextureAttr);
|
|
||||||
this->SetRotatesTexture(rotatesTexture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::RunOnMinMaxChangedScript() {
|
void CSimpleStatusBar::RunOnMinMaxChangedScript() {
|
||||||
if (!this->m_onMinMaxChanged.luaRef) {
|
if (!this->m_onMinMaxChanged.luaRef) {
|
||||||
return;
|
return;
|
||||||
@ -154,30 +85,6 @@ void CSimpleStatusBar::RunOnValueChangedScript() {
|
|||||||
this->RunScript(this->m_onValueChanged, 1, nullptr);
|
this->RunScript(this->m_onValueChanged, 1, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleStatusBar::SetBarTexture(CSimpleTexture* texture, int32_t drawlayer) {
|
|
||||||
// No change
|
|
||||||
if (this->m_barTexture == texture) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->m_barTexture) {
|
|
||||||
delete this->m_barTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texture) {
|
|
||||||
texture->SetFrame(this, drawlayer, true);
|
|
||||||
|
|
||||||
texture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
|
|
||||||
texture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, 0.0f, 0.0f, true);
|
|
||||||
texture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, 0.0f, true);
|
|
||||||
texture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, 0.0f, 0.0f, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->m_barTexture = texture;
|
|
||||||
|
|
||||||
this->m_changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetMinMaxValues(float min, float max) {
|
void CSimpleStatusBar::SetMinMaxValues(float min, float max) {
|
||||||
if (min > max) {
|
if (min > max) {
|
||||||
min = max;
|
min = max;
|
||||||
@ -201,20 +108,6 @@ void CSimpleStatusBar::SetMinMaxValues(float min, float max) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleStatusBar::SetOrientation(ORIENTATION orientation) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetRotatesTexture(int32_t enabled) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetStatusBarColor(const CImVector& color) {
|
|
||||||
if (this->m_barTexture) {
|
|
||||||
this->m_barTexture->SetVertexColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetValue(float value) {
|
void CSimpleStatusBar::SetValue(float value) {
|
||||||
if (!this->m_rangeSet) {
|
if (!this->m_rangeSet) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -20,24 +20,13 @@ class CSimpleStatusBar : public CSimpleFrame {
|
|||||||
virtual bool IsA(int32_t type);
|
virtual bool IsA(int32_t type);
|
||||||
// TODO
|
// TODO
|
||||||
virtual void SetValue(float value);
|
virtual void SetValue(float value);
|
||||||
virtual void LoadXML(const XMLNode* node, CStatus* status);
|
|
||||||
|
|
||||||
// Public member functions
|
// Public member functions
|
||||||
CSimpleStatusBar(CSimpleFrame* parent)
|
CSimpleStatusBar(CSimpleFrame* parent);
|
||||||
: CSimpleFrame(parent)
|
|
||||||
, m_changed(false)
|
|
||||||
, m_rangeSet(false)
|
|
||||||
, m_valueSet(false) {};
|
|
||||||
float GetMaxValue() const;
|
|
||||||
float GetMinValue() const;
|
|
||||||
float GetValue() const;
|
float GetValue() const;
|
||||||
void RunOnMinMaxChangedScript();
|
void RunOnMinMaxChangedScript();
|
||||||
void RunOnValueChangedScript();
|
void RunOnValueChangedScript();
|
||||||
void SetBarTexture(CSimpleTexture* texture, int32_t drawlayer);
|
|
||||||
void SetMinMaxValues(float min, float max);
|
void SetMinMaxValues(float min, float max);
|
||||||
void SetOrientation(ORIENTATION orientation);
|
|
||||||
void SetRotatesTexture(int32_t enabled);
|
|
||||||
void SetStatusBarColor(const CImVector& color);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Protected member variables
|
// Protected member variables
|
||||||
|
|||||||
@ -15,13 +15,7 @@ int32_t CSimpleStatusBar_SetOrientation(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleStatusBar_GetMinMaxValues(lua_State* L) {
|
int32_t CSimpleStatusBar_GetMinMaxValues(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
lua_pushnumber(L, statusBar->GetMinValue());
|
|
||||||
lua_pushnumber(L, statusBar->GetMaxValue());
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleStatusBar_SetMinMaxValues(lua_State* L) {
|
int32_t CSimpleStatusBar_SetMinMaxValues(lua_State* L) {
|
||||||
@ -89,15 +83,7 @@ int32_t CSimpleStatusBar_GetStatusBarColor(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleStatusBar_SetStatusBarColor(lua_State* L) {
|
int32_t CSimpleStatusBar_SetStatusBarColor(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
CImVector color = {};
|
|
||||||
FrameScript_GetColor(L, 2, color);
|
|
||||||
|
|
||||||
statusBar->SetStatusBarColor(color);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleStatusBar_GetRotatesTexture(lua_State* L) {
|
int32_t CSimpleStatusBar_GetRotatesTexture(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user