Skip to content

Commit

Permalink
Config + Source changes
Browse files Browse the repository at this point in the history
- Updated .gitignore
- Added Release configuration
- Changed fullscreen to match current GMS (v206.2)
- Added prompts for dropping items
- Fixed scaling issue on UINotice
- Added sliding effect for quickslots
  • Loading branch information
ryantpayton committed Aug 19, 2019
1 parent 0eb892c commit ddd67c8
Show file tree
Hide file tree
Showing 32 changed files with 287 additions and 154 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

*.nx
*.aps
*.log
*.tlog

Settings
3 changes: 2 additions & 1 deletion IO/Components/Icon.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
// This file is part of the Journey MMORPG client //
// Copyright © 2015-2016 Daniel Allendorf //
// Copyright © 2015-2016 Daniel Allendorf //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
Expand Down Expand Up @@ -86,6 +86,7 @@ namespace jrc
void Icon::set_count(int16_t c)
{
count = c;
type->set_count(c);
}

int16_t Icon::get_count() const
Expand Down
2 changes: 2 additions & 0 deletions IO/Components/Icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace jrc
virtual void drop_on_equips(Equipslot::Id eqslot) const = 0;
virtual void drop_on_items(InventoryType::Id tab, Equipslot::Id eqslot, int16_t slot, bool equip) const = 0;
virtual void drop_on_bindings(Point<int16_t> cursorposition, bool remove) const = 0;
virtual void set_count(int16_t) = 0;
};

class NullType : public Type
Expand All @@ -43,6 +44,7 @@ namespace jrc
void drop_on_equips(Equipslot::Id) const override {}
void drop_on_items(InventoryType::Id, Equipslot::Id, int16_t, bool) const override {}
void drop_on_bindings(Point<int16_t> cursorposition, bool remove) const override {}
void set_count(int16_t) override {}
};

Icon(std::unique_ptr<Type> type, Texture texture, int16_t count);
Expand Down
12 changes: 12 additions & 0 deletions IO/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ namespace jrc

void UI::send_key(int32_t keycode, bool pressed)
{
if ((is_key_down[GLFW_KEY_LEFT_ALT] || is_key_down[GLFW_KEY_RIGHT_ALT]) && (is_key_down[GLFW_KEY_ENTER] || is_key_down[GLFW_KEY_KP_ENTER]))
{
Window::get().toggle_fullscreen();

is_key_down[GLFW_KEY_LEFT_ALT] = false;
is_key_down[GLFW_KEY_RIGHT_ALT] = false;
is_key_down[GLFW_KEY_ENTER] = false;
is_key_down[GLFW_KEY_KP_ENTER] = false;

return;
}

if (is_key_down[keyboard.capslockcode()])
caps_lock_enabled = !caps_lock_enabled;

Expand Down
1 change: 1 addition & 0 deletions IO/UITypes/UIEquipInventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace jrc
void drop_on_equips(Equipslot::Id) const override {}
void drop_on_items(InventoryType::Id tab, Equipslot::Id eqslot, int16_t slot, bool equip) const override;
void drop_on_bindings(Point<int16_t>, bool) const override {}
void set_count(int16_t) override {}

private:
int16_t source;
Expand Down
67 changes: 64 additions & 3 deletions IO/UITypes/UIItemInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////
#include "UIItemInventory.h"
#include "UINotice.h"

#include "../UI.h"

Expand Down Expand Up @@ -168,11 +169,13 @@ namespace jrc
else
count = inventory.get_item_count(tab, slot);

const bool untradable = ItemData::get(item_id).is_untradable();
const bool cashitem = ItemData::get(item_id).is_cashitem();
const Texture& texture = ItemData::get(item_id).get_icon(false);
Equipslot::Id eqslot = inventory.find_equipslot(item_id);

icons[slot] = std::make_unique<Icon>(
std::make_unique<ItemIcon>(tab, eqslot, slot),
std::make_unique<ItemIcon>(tab, eqslot, slot, count, untradable, cashitem),
texture, count
);
}
Expand Down Expand Up @@ -594,16 +597,74 @@ namespace jrc
return nullptr;
}

UIItemInventory::ItemIcon::ItemIcon(InventoryType::Id st, Equipslot::Id eqs, int16_t s)
void UIItemInventory::ItemIcon::set_count(int16_t c)
{
count = c;
}

UIItemInventory::ItemIcon::ItemIcon(InventoryType::Id st, Equipslot::Id eqs, int16_t s, int16_t c, bool u, bool cash)
{
sourcetab = st;
eqsource = eqs;
source = s;
count = c;
untradable = u;
cashitem = cash;
}

void UIItemInventory::ItemIcon::drop_on_stage() const
{
MoveItemPacket(sourcetab, source, 0, 1).dispatch();
constexpr char* dropmessage = "How many will you drop?";
constexpr char* untradablemessage = "This item can't be taken back once thrown away.\\nWill you still drop it?";
constexpr char* cashmessage = "You can't drop this item.";

if (cashitem)
{
UI::get().emplace<UIOk>(cashmessage, []() {}, UINotice::NoticeType::OKSMALL);
}
else
{
if (untradable)
{
auto onok = [&, dropmessage](bool ok)
{
if (ok)
{
if (count <= 1)
{
MoveItemPacket(sourcetab, source, 0, 1).dispatch();
}
else
{
auto onenter = [&](int32_t qty)
{
MoveItemPacket(sourcetab, source, 0, qty).dispatch();
};

UI::get().emplace<UIEnterNumber>(dropmessage, onenter, count, count);
}
}
};

UI::get().emplace<UIYesNo>(untradablemessage, onok);
}
else
{
if (count <= 1)
{
MoveItemPacket(sourcetab, source, 0, 1).dispatch();
}
else
{
auto onenter = [&](int32_t qty)
{
MoveItemPacket(sourcetab, source, 0, qty).dispatch();
};

UI::get().emplace<UIEnterNumber>(dropmessage, onenter, count, count);
}
}
}
}

void UIItemInventory::ItemIcon::drop_on_equips(Equipslot::Id eqslot) const
Expand Down
6 changes: 5 additions & 1 deletion IO/UITypes/UIItemInventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,21 @@ namespace jrc
class ItemIcon : public Icon::Type
{
public:
ItemIcon(InventoryType::Id sourcetab, Equipslot::Id eqsource, int16_t source);
ItemIcon(InventoryType::Id sourcetab, Equipslot::Id eqsource, int16_t source, int16_t count, bool untradable, bool cashitem);

void drop_on_stage() const override;
void drop_on_equips(Equipslot::Id eqslot) const override;
void drop_on_items(InventoryType::Id tab, Equipslot::Id, int16_t slot, bool) const override;
void drop_on_bindings(Point<int16_t>, bool) const override {};
void set_count(int16_t count) override;

private:
InventoryType::Id sourcetab;
Equipslot::Id eqsource;
int16_t source;
int16_t count;
bool untradable;
bool cashitem;
};

enum Buttons
Expand Down
Loading

0 comments on commit ddd67c8

Please sign in to comment.