Skip to content

Commit

Permalink
starting to wire up chests gui
Browse files Browse the repository at this point in the history
  • Loading branch information
efroemling committed Dec 19, 2024
1 parent 02ac804 commit 05f09c9
Show file tree
Hide file tree
Showing 15 changed files with 373 additions and 234 deletions.
74 changes: 37 additions & 37 deletions .efrocachemap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.7.37 (build 22138, api 9, 2024-12-19)
### 1.7.37 (build 22139, api 9, 2024-12-19)
- Bumping api version to 9. As you'll see below, there's some UI changes that
will require a bit of work for any UI mods to adapt to. If your mods don't
touch UI stuff at all you can simply bump your api version and call it a day.
Expand Down
28 changes: 25 additions & 3 deletions src/assets/ba_data/python/baclassic/_appmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def on_activate(self) -> None:
ui.root_ui_calls[ui.RootUIElement.ACHIEVEMENTS_BUTTON] = (
self._root_ui_achievements_press
)
ui.root_ui_calls[ui.RootUIElement.CHEST_SLOT_0] = partial(
self._root_ui_chest_slot_pressed, 0
)
ui.root_ui_calls[ui.RootUIElement.CHEST_SLOT_1] = partial(
self._root_ui_chest_slot_pressed, 1
)
Expand All @@ -113,9 +116,6 @@ def on_activate(self) -> None:
ui.root_ui_calls[ui.RootUIElement.CHEST_SLOT_3] = partial(
self._root_ui_chest_slot_pressed, 3
)
ui.root_ui_calls[ui.RootUIElement.CHEST_SLOT_4] = partial(
self._root_ui_chest_slot_pressed, 4
)

# We want to be informed when primary account changes.
self._on_primary_account_changed_callback = (
Expand Down Expand Up @@ -189,6 +189,10 @@ def update_for_primary_account(
xp_text='-',
inbox_count_text='',
gold_pass=False,
chest_0_appearance='',
chest_1_appearance='',
chest_2_appearance='',
chest_3_appearance='',
)

else:
Expand All @@ -210,6 +214,12 @@ def _on_classic_account_data_change(
ibc = str(val.inbox_count)
if val.inbox_count_is_max:
ibc += '+'

chest0 = val.chests.get('0')
chest1 = val.chests.get('1')
chest2 = val.chests.get('2')
chest3 = val.chests.get('3')

_baclassic.set_root_ui_values(
tickets_text=str(val.tickets),
tokens_text=str(val.tokens),
Expand All @@ -224,6 +234,18 @@ def _on_classic_account_data_change(
xp_text=f'{val.xp}/{val.xpmax}',
inbox_count_text=ibc,
gold_pass=val.gold_pass,
chest_0_appearance=(
'' if chest0 is None else chest0.appearance.value
),
chest_1_appearance=(
'' if chest1 is None else chest1.appearance.value
),
chest_2_appearance=(
'' if chest2 is None else chest2.appearance.value
),
chest_3_appearance=(
'' if chest3 is None else chest3.appearance.value
),
)

def _root_ui_menu_press(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/assets/ba_data/python/baenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 22138
TARGET_BALLISTICA_BUILD = 22139
TARGET_BALLISTICA_VERSION = '1.7.37'


Expand Down
2 changes: 1 addition & 1 deletion src/assets/ba_data/python/bauiv1/_appsubsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class RootUIElement(Enum):
TOKENS_METER = 'tokens_meter'
TROPHY_METER = 'trophy_meter'
LEVEL_METER = 'level_meter'
CHEST_SLOT_0 = 'chest_slot_0'
CHEST_SLOT_1 = 'chest_slot_1'
CHEST_SLOT_2 = 'chest_slot_2'
CHEST_SLOT_3 = 'chest_slot_3'
CHEST_SLOT_4 = 'chest_slot_4'

def __init__(self) -> None:
from bauiv1._uitypes import MainWindow
Expand Down
12 changes: 6 additions & 6 deletions src/assets/ba_data/python/bauiv1/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def root_ui_store_button_press() -> None:
_root_ui_button_press(UIV1AppSubsystem.RootUIElement.STORE_BUTTON)


def root_ui_chest_slot_0_press() -> None:
from bauiv1._appsubsystem import UIV1AppSubsystem

_root_ui_button_press(UIV1AppSubsystem.RootUIElement.CHEST_SLOT_0)


def root_ui_chest_slot_1_press() -> None:
from bauiv1._appsubsystem import UIV1AppSubsystem

Expand All @@ -81,12 +87,6 @@ def root_ui_chest_slot_3_press() -> None:
_root_ui_button_press(UIV1AppSubsystem.RootUIElement.CHEST_SLOT_3)


def root_ui_chest_slot_4_press() -> None:
from bauiv1._appsubsystem import UIV1AppSubsystem

_root_ui_button_press(UIV1AppSubsystem.RootUIElement.CHEST_SLOT_4)


def root_ui_inventory_button_press() -> None:
from bauiv1._appsubsystem import UIV1AppSubsystem

Expand Down
24 changes: 20 additions & 4 deletions src/ballistica/classic/python/methods/python_methods_classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds)
const char* level_text;
const char* xp_text;
const char* inbox_count_text;
const char* chest_0_appearance;
const char* chest_1_appearance;
const char* chest_2_appearance;
const char* chest_3_appearance;
int gold_pass{};

static const char* kwlist[] = {"tickets_text",
Expand All @@ -314,12 +318,17 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds)
"xp_text",
"inbox_count_text",
"gold_pass",
"chest_0_appearance",
"chest_1_appearance",
"chest_2_appearance",
"chest_3_appearance",
nullptr};
if (!PyArg_ParseTupleAndKeywords(
args, keywds, "ssssssssp", const_cast<char**>(kwlist), &tickets_text,
&tokens_text, &league_rank_text, &league_type,
args, keywds, "sssssssspssss", const_cast<char**>(kwlist),
&tickets_text, &tokens_text, &league_rank_text, &league_type,
&achievements_percent_text, &level_text, &xp_text, &inbox_count_text,
&gold_pass)) {
&gold_pass, &chest_0_appearance, &chest_1_appearance,
&chest_2_appearance, &chest_3_appearance)) {
return nullptr;
}
BA_PRECONDITION(g_base->InLogicThread());
Expand All @@ -337,6 +346,8 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds)
appmode->SetRootUIXPText(xp_text);
appmode->SetRootUIInboxCountText(inbox_count_text);
appmode->SetRootUIGoldPass(gold_pass);
appmode->SetRootUIChests(chest_0_appearance, chest_1_appearance,
chest_2_appearance, chest_3_appearance);

Py_RETURN_NONE;
BA_PYTHON_CATCH;
Expand All @@ -347,7 +358,8 @@ static PyMethodDef PySetRootUIValuesDef = {
(PyCFunction)PySetRootUIValues, // method
METH_VARARGS | METH_KEYWORDS, // flags

"set_root_ui_values(tickets_text: str,\n"
"set_root_ui_values(*,\n"
" tickets_text: str,\n"
" tokens_text: str,\n"
" league_rank_text: str,\n"
" league_type: str,\n"
Expand All @@ -356,6 +368,10 @@ static PyMethodDef PySetRootUIValuesDef = {
" xp_text: str,\n"
" inbox_count_text: str,\n"
" gold_pass: bool,\n"
" chest_0_appearance: str,\n"
" chest_1_appearance: str,\n"
" chest_2_appearance: str,\n"
" chest_3_appearance: str,\n"
") -> None\n"
"\n"
"(internal)",
Expand Down
31 changes: 31 additions & 0 deletions src/ballistica/classic/support/classic_app_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ void ClassicAppMode::Reset_() {
root_widget->SetLevelText(root_ui_level_text_);
root_widget->SetXPText(root_ui_xp_text_);
root_widget->SetInboxCountText(root_ui_inbox_count_text_);
root_widget->SetChests(
root_ui_chest_0_appearance_, root_ui_chest_1_appearance_,
root_ui_chest_2_appearance_, root_ui_chest_3_appearance_);
}
}

Expand Down Expand Up @@ -1696,6 +1699,34 @@ void ClassicAppMode::SetRootUIGoldPass(bool enabled) {
}
}

void ClassicAppMode::SetRootUIChests(const std::string& chest_0_appearance,
const std::string& chest_1_appearance,
const std::string& chest_2_appearance,
const std::string& chest_3_appearance) {
BA_PRECONDITION(g_base->InLogicThread());
if (chest_0_appearance == root_ui_chest_0_appearance_
&& chest_1_appearance == root_ui_chest_1_appearance_
&& chest_2_appearance == root_ui_chest_2_appearance_
&& chest_3_appearance == root_ui_chest_3_appearance_) {
return;
}

// Store the values.
root_ui_chest_0_appearance_ = chest_0_appearance;
root_ui_chest_1_appearance_ = chest_1_appearance;
root_ui_chest_2_appearance_ = chest_2_appearance;
root_ui_chest_3_appearance_ = chest_3_appearance;

// Apply it to any existing UI.
if (uiv1_) {
if (auto* root_widget = uiv1_->root_widget()) {
root_widget->SetChests(
root_ui_chest_0_appearance_, root_ui_chest_1_appearance_,
root_ui_chest_2_appearance_, root_ui_chest_3_appearance_);
}
}
}

auto ClassicAppMode::GetBottomLeftEdgeHeight() -> float {
assert(g_base->InLogicThread());
if (uiv1_) {
Expand Down
8 changes: 8 additions & 0 deletions src/ballistica/classic/support/classic_app_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ class ClassicAppMode : public base::AppMode {
void SetRootUIXPText(const std::string text);
void SetRootUIInboxCountText(const std::string text);
void SetRootUIGoldPass(bool enabled);
void SetRootUIChests(const std::string& chest_0_appearance,
const std::string& chest_1_appearance,
const std::string& chest_2_appearance,
const std::string& chest_3_appearance);

private:
ClassicAppMode();
Expand All @@ -241,6 +245,10 @@ class ClassicAppMode : public base::AppMode {
// forward declarations of their template params.
std::map<std::string, ScanResultsEntryPriv_> scan_results_;
std::mutex scan_results_mutex_;
std::string root_ui_chest_0_appearance_;
std::string root_ui_chest_1_appearance_;
std::string root_ui_chest_2_appearance_;
std::string root_ui_chest_3_appearance_;
uint32_t next_scan_query_id_{};
int scan_socket_{-1};
int host_protocol_version_{-1};
Expand Down
2 changes: 1 addition & 1 deletion src/ballistica/shared/ballistica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {

// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 22138;
const int kEngineBuildNumber = 22139;
const char* kEngineVersion = "1.7.37";
const int kEngineApiVersion = 9;

Expand Down
2 changes: 1 addition & 1 deletion src/ballistica/ui_v1/python/ui_v1_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class UIV1Python {
kRootUISettingsButtonPressCall,
kRootUIAchievementsButtonPressCall,
kRootUIStoreButtonPressCall,
kRootUIChestSlot0PressCall,
kRootUIChestSlot1PressCall,
kRootUIChestSlot2PressCall,
kRootUIChestSlot3PressCall,
kRootUIChestSlot4PressCall,
kRootUIInventoryButtonPressCall,
kRootUITrophyMeterPressCall,
kRootUILevelIconPressCall,
Expand Down
Loading

0 comments on commit 05f09c9

Please sign in to comment.