DinkSmallwoodHD/source/Component/InventoryComponent.cpp
seth 36a414e12a * (Windows) Running "dink.exe c:\temp\ACoolDMOD.dmod" from the command line will now install it, then run it. (original dmod file won't be deleted) Just seemed weird that this didn't exist so added it
* DMOD installer progress now switches to showing MB instead of K if the size is big
* BUGFIX: Fixed map loading bug that could crash the game (I added this one recently trying to clean up code to use more consts rather than magic #s, but there is always the risk I stupidely break something!)
* load_tile no longer instantly takes effect but requires a draw_screen or moving screens, this matches how 1.08 worked.  Loading a save state or resizing the window will cause it to happen early, but hey, close enough
* BUGFIX: Fixed extra nasty bug where logic on certain things like charging your magic would pause the amount of time you used TAB to skip time

git-svn-id: svn://rtsoft.com/rtsvn/projects/RTDink@1517 353e56fe-9613-0410-8469-b96ad8e6f29c
2017-10-02 13:48:06 +00:00

113 lines
2.6 KiB
C++

#include "PlatformPrecomp.h"
#include "InventoryComponent.h"
#include "util/GLESUtils.h"
#include "Entity/EntityUtils.h"
#include "BaseApp.h"
InventoryComponent::InventoryComponent()
{
m_activeFinger = -1;
SetName("Inventory");
}
InventoryComponent::~InventoryComponent()
{
}
void InventoryComponent::OnAdd(Entity *pEnt)
{
EntityComponent::OnAdd(pEnt);
m_pArrowEnt = NULL;
m_bGotFirstClick = false;
m_pPos2d = &GetParent()->GetVar("pos2d")->GetVector2();
//register ourselves to render if the parent does
GetParent()->GetFunction("OnRender")->sig_function.connect(1, boost::bind(&InventoryComponent::OnRender, this, _1));
GetParent()->GetFunction("OnUpdate")->sig_function.connect(1, boost::bind(&InventoryComponent::OnUpdate, this, _1));
AddInputMovementFocusIfNeeded(GetParent());
GetParent()->GetFunction("OnInput")->sig_function.connect(1, boost::bind(&InventoryComponent::OnInput, this, _1));
}
void InventoryComponent::OnRemove()
{
EntityComponent::OnRemove();
}
void InventoryComponent::OnUpdatePos(CL_Vec2f vPos)
{
//LogMsg("Got %s", PrintVector2(vPos).c_str());
DinkSetInventoryPosition(NativeToDinkCoords(vPos));
}
void InventoryComponent::OnRender(VariantList *pVList)
{
//CL_Vec2f vFinalPos = pVList->m_variant[0].GetVector2()+*m_pPos2d;
}
void InventoryComponent::OnUpdate(VariantList *pVList)
{
}
void InventoryComponent::OnInput( VariantList *pVList )
{
//0 = message type, 1 = parent coordinate offset
CL_Vec2f pt = pVList->Get(1).GetVector2();
//pt += GetAlignmentOffset(*m_pSize2d, eAlignment(*m_pAlignment));
switch (eMessageType( int(pVList->Get(0).GetFloat())))
{
case MESSAGE_TYPE_GUI_CLICK_START:
{
uint32 fingerID = pVList->Get(2).GetUINT32();
TouchTrackInfo *pTouch = GetBaseApp()->GetTouch(fingerID);
if (pTouch->WasHandled()) return;
pTouch->SetWasHandled(true);
m_activeFinger = fingerID;
}
OnUpdatePos(pt);
break;
case MESSAGE_TYPE_GUI_CLICK_END:
{
uint32 fingerID = pVList->Get(2).GetUINT32();
if (fingerID == m_activeFinger)
{
OnUpdatePos(pt);
/*
if (!m_bGotFirstClick)
{
//ignore this, they are just releasing from the previous menu's button
m_bGotFirstClick = true;
} else
{
*/
if (DinkSetInventoryPosition(NativeToDinkCoords(pt)))
{
g_dglo.m_dirInput[DINK_INPUT_BUTTON1] = true;
g_dglo.m_dirInputFinished[DINK_INPUT_BUTTON1] = true;
}
}
}
//HandleClickEnd(pt);
break;
case MESSAGE_TYPE_GUI_CLICK_MOVE:
{
uint32 fingerID = pVList->Get(2).GetUINT32();
if (fingerID == m_activeFinger) OnUpdatePos(pt);
}
break;
}
}