mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-19 06:01:07 +03:00
Compare commits
4 Commits
35f0f47419
...
cfc7c5588c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfc7c5588c | ||
|
|
aa22dd952a | ||
|
|
534e05be93 | ||
|
|
a82628adaa |
@ -160,6 +160,10 @@ ClientConnection* ClientServices::Connection() {
|
||||
return ClientServices::s_currentConnection;
|
||||
}
|
||||
|
||||
void ClientServices::CharacterDelete(uint64_t guid) {
|
||||
ClientServices::Connection()->RequestCharacterDelete(guid);
|
||||
}
|
||||
|
||||
void ClientServices::Disconnect() {
|
||||
ClientServices::Connection()->Disconnect();
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ class ClientServices : public LoginResponse {
|
||||
// Static functions
|
||||
static void ConnectToSelectedServer();
|
||||
static ClientConnection* Connection();
|
||||
static void CharacterDelete(uint64_t guid);
|
||||
static void Disconnect();
|
||||
static const char* GetCurrentLoginPortal();
|
||||
static const char* GetCurrentLoginServer();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "glue/CCharacterSelectionScript.hpp"
|
||||
#include "CGlueMgr.hpp"
|
||||
#include "db/Db.hpp"
|
||||
#include "glue/CCharacterSelection.hpp"
|
||||
#include "object/client/CGUnit_C.hpp"
|
||||
@ -157,7 +158,17 @@ int32_t Script_SelectCharacter(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_DeleteCharacter(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
if (!lua_isnumber(L, 1)) {
|
||||
luaL_error(L, "Usage: DeleteCharacter(index)");
|
||||
}
|
||||
|
||||
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
|
||||
|
||||
if (index >= 0 && index < CCharacterSelection::s_characterList.Count()) {
|
||||
CGlueMgr::DeleteCharacter(CCharacterSelection::s_characterList.m_data[index].m_info.guid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Script_RenameCharacter(lua_State* L) {
|
||||
|
||||
@ -129,6 +129,17 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
|
||||
ClientServices::Connection()->Connect();
|
||||
}
|
||||
|
||||
void CGlueMgr::DeleteCharacter(uint64_t guid) {
|
||||
if (guid) {
|
||||
CGlueMgr::SetIdleState(IDLE_DELETE_CHARACTER);
|
||||
|
||||
auto text = FrameScript_GetText(ClientServices::GetErrorToken(70), -1, GENDER_NOT_APPLICABLE);
|
||||
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "CANCEL", text);
|
||||
|
||||
ClientServices::CharacterDelete(guid);
|
||||
}
|
||||
}
|
||||
|
||||
void CGlueMgr::EnterWorld() {
|
||||
if (!ClientServices::GetSelectedRealm()) {
|
||||
return;
|
||||
|
||||
@ -66,6 +66,7 @@ class CGlueMgr {
|
||||
// Static functions
|
||||
static void CancelRealmListQuery();
|
||||
static void ChangeRealm(const REALM_INFO* realmInfo);
|
||||
static void DeleteCharacter(uint64_t guid);
|
||||
static void DisplayLoginStatus();
|
||||
static void EnterWorld();
|
||||
static void GetCharacterList();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "net/connection/ClientConnection.hpp"
|
||||
#include "net/Login.hpp"
|
||||
#include "client/ClientServices.hpp"
|
||||
#include "common/datastore/CDataStore.hpp"
|
||||
#include "net/Login.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
|
||||
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
|
||||
@ -160,3 +161,19 @@ int32_t ClientConnection::PollStatus(WOWCS_OPS& op, const char** msg, int32_t& r
|
||||
|
||||
return this->m_statusComplete;
|
||||
}
|
||||
|
||||
void ClientConnection::RequestCharacterDelete(uint64_t guid) {
|
||||
this->Initiate(COP_DELETE_CHARACTER, 70, nullptr);
|
||||
|
||||
if (this->IsConnected()) {
|
||||
CDataStore netMsg;
|
||||
netMsg.Put(static_cast<uint32_t>(CMSG_CHAR_DELETE));
|
||||
netMsg.Put(guid);
|
||||
netMsg.Finalize();
|
||||
|
||||
this->Send(&netMsg);
|
||||
}
|
||||
else {
|
||||
this->Cancel(4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ class ClientConnection : public RealmConnection {
|
||||
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
|
||||
int32_t IsConnected();
|
||||
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
|
||||
void RequestCharacterDelete(uint64_t guid);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -332,6 +332,10 @@ void CLayoutFrame::GetFirstPointY(const FRAMEPOINT* const pointarray, int32_t el
|
||||
}
|
||||
}
|
||||
|
||||
float CLayoutFrame::GetHeight() {
|
||||
return this->m_height;
|
||||
}
|
||||
|
||||
CLayoutFrame* CLayoutFrame::GetLayoutFrameByName(const char* name) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -353,8 +357,20 @@ int32_t CLayoutFrame::GetRect(CRect* rect) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
float CLayoutFrame::GetHeight() {
|
||||
return this->m_height;
|
||||
void CLayoutFrame::GetSize(float& width, float& height, int32_t a4) {
|
||||
width = this->GetWidth();
|
||||
height = this->GetHeight();
|
||||
|
||||
if (!a4 && (width == 0.0f || height == 0.0f)) {
|
||||
if (this->m_flags & FLAG_RESIZE_PENDING) {
|
||||
this->Resize(1);
|
||||
}
|
||||
|
||||
if (this->m_flags & 0x1) {
|
||||
width = (this->m_rect.maxX - this->m_rect.minX) / this->m_layoutScale;
|
||||
height = (this->m_rect.maxY - this->m_rect.minY) / this->m_layoutScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float CLayoutFrame::GetWidth() {
|
||||
|
||||
@ -51,6 +51,7 @@ class CLayoutFrame {
|
||||
virtual void SetHeight(float height);
|
||||
virtual float GetWidth();
|
||||
virtual float GetHeight();
|
||||
virtual void GetSize(float& width, float& height, int32_t a4);
|
||||
virtual void GetClampRectInsets(float& a1, float& a2, float& a3, float& a4);
|
||||
virtual int32_t IsAttachmentOrigin();
|
||||
virtual CLayoutFrame* GetLayoutFrameByName(const char* name);
|
||||
|
||||
@ -28,6 +28,16 @@ void CSimpleStatusBar::RegisterScriptMethods(lua_State* L) {
|
||||
FrameScript_Object::FillScriptMethodTable(L, SimpleStatusBarMethods, NUM_SIMPLE_STATUS_BAR_SCRIPT_METHODS);
|
||||
}
|
||||
|
||||
float CSimpleStatusBar::GetAnimValue() const {
|
||||
auto range = this->m_maxValue - this->m_minValue;
|
||||
|
||||
if (range <= 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return (this->m_value - this->m_minValue) / range;
|
||||
}
|
||||
|
||||
FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name, ScriptData& data) {
|
||||
auto script = this->CSimpleFrame::GetScriptByName(name, data);
|
||||
|
||||
@ -129,6 +139,46 @@ void CSimpleStatusBar::LoadXML(const XMLNode* node, CStatus* status) {
|
||||
}
|
||||
}
|
||||
|
||||
void CSimpleStatusBar::OnLayerUpdate(float elapsedSec) {
|
||||
this->CSimpleFrame::OnLayerUpdate(elapsedSec);
|
||||
|
||||
if (!this->m_changed || !this->m_rangeSet || !this->m_valueSet || !this->m_barTexture) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto animValue = this->GetAnimValue();
|
||||
|
||||
if (animValue <= 0.0f) {
|
||||
this->m_barTexture->Hide();
|
||||
this->m_changed = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float width, height;
|
||||
this->GetSize(width, height, false);
|
||||
|
||||
auto fill = 1.0f - animValue;
|
||||
|
||||
this->m_barTexture->Show();
|
||||
|
||||
if (this->m_orientation == ORIENTATION_VERTICAL) {
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, 0.0f, 0.0f, true);
|
||||
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, -(fill * height), true);
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, 0.0f, -(fill * height), true);
|
||||
} else {
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, 0.0f, true);
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
|
||||
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, -(fill * width), 0.0f, true);
|
||||
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, -(fill * width), 0.0f, true);
|
||||
}
|
||||
|
||||
this->m_changed = false;
|
||||
}
|
||||
|
||||
void CSimpleStatusBar::RunOnMinMaxChangedScript() {
|
||||
if (!this->m_onMinMaxChanged.luaRef) {
|
||||
return;
|
||||
|
||||
@ -19,6 +19,8 @@ class CSimpleStatusBar : public CSimpleFrame {
|
||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||
virtual bool IsA(int32_t type);
|
||||
// TODO
|
||||
virtual void OnLayerUpdate(float elapsedSec);
|
||||
// TODO
|
||||
virtual void SetValue(float value);
|
||||
virtual void LoadXML(const XMLNode* node, CStatus* status);
|
||||
|
||||
@ -28,6 +30,7 @@ class CSimpleStatusBar : public CSimpleFrame {
|
||||
, m_changed(false)
|
||||
, m_rangeSet(false)
|
||||
, m_valueSet(false) {};
|
||||
float GetAnimValue() const;
|
||||
float GetMaxValue() const;
|
||||
float GetMinValue() const;
|
||||
float GetValue() const;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user