mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
* Outline all the Mouse and Keyboard code.
This commit is contained in:
@@ -293,42 +293,28 @@ void Screen::updateEvents()
|
||||
{
|
||||
if (field_10) return;
|
||||
|
||||
for (int i = Mouse::_index + 1; i<int(Mouse::_inputs.size()); i++)
|
||||
{
|
||||
Mouse::_index = i;
|
||||
while (Mouse::next())
|
||||
mouseEvent();
|
||||
}
|
||||
|
||||
for (int i = Keyboard::_index + 1; i<int(Keyboard::_inputs.size()); i++)
|
||||
{
|
||||
Keyboard::_index = i;
|
||||
while (Keyboard::next())
|
||||
keyboardEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::keyboardEvent()
|
||||
{
|
||||
// @UB: This probably behaves in an unexpected way if _inputs is empty
|
||||
|
||||
#ifndef ORIGINAL_CODE
|
||||
if (Keyboard::_inputs.empty() || Keyboard::_index < 0)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (Keyboard::_inputs[Keyboard::_index].field_0)
|
||||
keyPressed(Keyboard::_inputs[Keyboard::_index].field_4);
|
||||
if (Keyboard::getEventKeyState())
|
||||
keyPressed(Keyboard::getEventKey());
|
||||
}
|
||||
|
||||
void Screen::mouseEvent()
|
||||
{
|
||||
MouseInput& inp = Mouse::_inputs[Mouse::_index];
|
||||
|
||||
if (1 <= inp.field_0 && inp.field_0 <= 2)
|
||||
MouseAction* pAction = Mouse::getEvent();
|
||||
if (pAction->isButton())
|
||||
{
|
||||
if (inp.field_4 == 1)
|
||||
mouseClicked(m_width * Mouse::_x / Minecraft::width, m_height * Mouse::_y / Minecraft::height - 1, inp.field_0);
|
||||
if (Mouse::getEventButtonState())
|
||||
mouseClicked (m_width * pAction->field_8 / Minecraft::width, m_height * pAction->field_C / Minecraft::height - 1, Mouse::getEventButton());
|
||||
else
|
||||
mouseReleased(m_width * Mouse::_x / Minecraft::width, m_height * Mouse::_y / Minecraft::height - 1, inp.field_0);
|
||||
mouseReleased(m_width * pAction->field_8 / Minecraft::width, m_height * pAction->field_C / Minecraft::height - 1, Mouse::getEventButton());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f)
|
||||
int nItems = getNumberOfItems();
|
||||
|
||||
// @TODO: fix gotos.
|
||||
if (!Mouse::_buttonStates[1])
|
||||
if (!Mouse::isButtonDown(1))
|
||||
{
|
||||
if (field_28 < 0)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ void ScrolledSelectionList::render(int mouseX, int mouseY, float f)
|
||||
renderBackground();
|
||||
|
||||
int nItems = getNumberOfItems();
|
||||
if (Mouse::_buttonStates[1])
|
||||
if (Mouse::isButtonDown(1))
|
||||
{
|
||||
if (float(mouseY) >= field_C && float(mouseY) <= field_10 && mouseY != field_28)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ void WorldSelectionList::tick()
|
||||
{
|
||||
RolledSelectionList::tick();
|
||||
field_D0++;
|
||||
if (Mouse::_buttonStates[1] || !field_28)
|
||||
if (Mouse::isButtonDown(1) || !field_28)
|
||||
return;
|
||||
|
||||
m_selectedIndex = -1;
|
||||
|
||||
@@ -40,7 +40,7 @@ void SelectWorldScreen::init()
|
||||
m_buttons.push_back(&m_btnBack);
|
||||
m_buttons.push_back(&m_btnDelete);
|
||||
|
||||
field_12C = Mouse::_buttonStates[1] == 0;
|
||||
field_12C = Mouse::getButtonState(1) == 0;
|
||||
|
||||
m_buttonTabList.push_back(&m_btnUnknown);
|
||||
m_buttonTabList.push_back(&m_btnDelete);
|
||||
@@ -168,7 +168,7 @@ void SelectWorldScreen::render(int mouseX, int mouseY, float f)
|
||||
else
|
||||
{
|
||||
m_pWorldSelectionList->render(0, 0, f);
|
||||
field_12C = Mouse::_buttonStates[1] == 0;
|
||||
field_12C = Mouse::getButtonState(1) == 0;
|
||||
}
|
||||
|
||||
Screen::render(mouseX, mouseY, f);
|
||||
|
||||
Reference in New Issue
Block a user