Skip to content

Commit

Permalink
some toolbar ui values now wired up (no animations yet though)
Browse files Browse the repository at this point in the history
  • Loading branch information
efroemling committed Nov 27, 2024
1 parent 8f176d2 commit a78dc70
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 47 deletions.
48 changes: 24 additions & 24 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 22113, api 9, 2024-11-26)
### 1.7.37 (build 22114, api 9, 2024-11-26)
- 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
30 changes: 15 additions & 15 deletions src/assets/ba_data/python/baclassic/_appmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from bacommon.app import AppExperience
import babase
import bauiv1

import _baclassic

Expand All @@ -18,7 +19,6 @@

from efro.call import CallbackRegistration
import bacommon.cloud
import bauiv1


# ba_meta export babase.AppMode
Expand Down Expand Up @@ -179,6 +179,12 @@ def update_for_primary_account(

if account is None:
self._account_data_sub = None
_baclassic.set_root_ui_values(
tickets_text='-',
tokens_text='-',
league_rank_text='-',
)

else:
with account:
self._account_data_sub = (
Expand All @@ -193,8 +199,15 @@ def _on_sub_test_update(self, val: int | None) -> None:
def _on_classic_account_data_change(
self, val: bacommon.cloud.ClassicAccountLiveData
) -> None:
pass
# pass
# print(f'GOT CLASSIC ACCOUNT DATA: {val}')
_baclassic.set_root_ui_values(
tickets_text=str(val.tickets),
tokens_text=str(val.tokens),
league_rank_text=(
'-' if val.league_rank is None else f'#{val.league_rank}'
),
)

def _root_ui_menu_press(self) -> None:
from babase import push_back_press
Expand All @@ -215,7 +228,6 @@ def _root_ui_menu_press(self) -> None:
push_back_press()

def _root_ui_account_press(self) -> None:
import bauiv1
from bauiv1lib.account.settings import AccountSettingsWindow

self._auxiliary_window_nav(
Expand All @@ -226,8 +238,6 @@ def _root_ui_account_press(self) -> None:
)

def _root_ui_squad_press(self) -> None:
import bauiv1

btn = bauiv1.get_special_widget('squad_button')
center = btn.get_screen_space_center()
if bauiv1.app.classic is not None:
Expand All @@ -236,7 +246,6 @@ def _root_ui_squad_press(self) -> None:
logging.warning('party_icon_activate: no classic.')

def _root_ui_settings_press(self) -> None:
import bauiv1
from bauiv1lib.settings.allsettings import AllSettingsWindow

self._auxiliary_window_nav(
Expand Down Expand Up @@ -342,7 +351,6 @@ def _auxiliary_window_nav(
)

def _root_ui_achievements_press(self) -> None:
import bauiv1
from bauiv1lib.achievements import AchievementsWindow

self._auxiliary_window_nav(
Expand All @@ -353,7 +361,6 @@ def _root_ui_achievements_press(self) -> None:
)

def _root_ui_inbox_press(self) -> None:
import bauiv1
from bauiv1lib.inbox import InboxWindow

self._auxiliary_window_nav(
Expand All @@ -364,7 +371,6 @@ def _root_ui_inbox_press(self) -> None:
)

def _root_ui_store_press(self) -> None:
import bauiv1
from bauiv1lib.store.browser import StoreBrowserWindow

self._auxiliary_window_nav(
Expand All @@ -375,23 +381,20 @@ def _root_ui_store_press(self) -> None:
)

def _root_ui_tickets_meter_press(self) -> None:
import bauiv1
from bauiv1lib.resourcetypeinfo import ResourceTypeInfoWindow

ResourceTypeInfoWindow(
'tickets', origin_widget=bauiv1.get_special_widget('tickets_meter')
)

def _root_ui_tokens_meter_press(self) -> None:
import bauiv1
from bauiv1lib.resourcetypeinfo import ResourceTypeInfoWindow

ResourceTypeInfoWindow(
'tokens', origin_widget=bauiv1.get_special_widget('tokens_meter')
)

def _root_ui_trophy_meter_press(self) -> None:
import bauiv1
from bauiv1lib.account import show_sign_in_prompt
from bauiv1lib.league.rankwindow import LeagueRankWindow

Expand All @@ -409,15 +412,13 @@ def _root_ui_trophy_meter_press(self) -> None:
)

def _root_ui_level_meter_press(self) -> None:
import bauiv1
from bauiv1lib.resourcetypeinfo import ResourceTypeInfoWindow

ResourceTypeInfoWindow(
'xp', origin_widget=bauiv1.get_special_widget('level_meter')
)

def _root_ui_inventory_press(self) -> None:
import bauiv1
from bauiv1lib.inventory import InventoryWindow

self._auxiliary_window_nav(
Expand All @@ -428,7 +429,6 @@ def _root_ui_inventory_press(self) -> None:
)

def _root_ui_get_tokens_press(self) -> None:
import bauiv1
from bauiv1lib.gettokens import GetTokensWindow

self._auxiliary_window_nav(
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 = 22113
TARGET_BALLISTICA_BUILD = 22114
TARGET_BALLISTICA_VERSION = '1.7.37'


Expand Down
5 changes: 5 additions & 0 deletions src/ballistica/classic/classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
#include "ballistica/scene_v1/python/scene_v1_python.h"
#include "ballistica/scene_v1/support/player_spec.h"
#include "ballistica/shared/generic/utils.h"
#include "ballistica/ui_v1/ui_v1.h"

namespace ballistica::classic {

core::CoreFeatureSet* g_core{};
base::BaseFeatureSet* g_base{};
ClassicFeatureSet* g_classic{};
scene_v1::SceneV1FeatureSet* g_scene_v1{};
ui_v1::UIV1FeatureSet* g_ui_v1{};

void ClassicFeatureSet::OnModuleExec(PyObject* module) {
// Ok, our feature-set's Python module is getting imported.
Expand Down Expand Up @@ -54,6 +56,9 @@ void ClassicFeatureSet::OnModuleExec(PyObject* module) {
assert(g_scene_v1 == nullptr);
g_scene_v1 = scene_v1::SceneV1FeatureSet::Import();

assert(g_ui_v1 == nullptr);
g_ui_v1 = ui_v1::UIV1FeatureSet::Import();

g_core->Log(LogName::kBaLifecycle, LogLevel::kInfo, "_baclassic exec end");
}

Expand Down
4 changes: 4 additions & 0 deletions src/ballistica/classic/classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class BaseFeatureSet;
namespace ballistica::scene_v1 {
class SceneV1FeatureSet;
}
namespace ballistica::ui_v1 {
class UIV1FeatureSet;
}

namespace ballistica::classic {

Expand Down Expand Up @@ -64,6 +67,7 @@ extern core::CoreFeatureSet* g_core;
extern base::BaseFeatureSet* g_base;
extern ClassicFeatureSet* g_classic;
extern scene_v1::SceneV1FeatureSet* g_scene_v1;
extern ui_v1::UIV1FeatureSet* g_ui_v1;

/// Our C++ front-end to our feature set. This is what other C++
/// feature-sets can 'Import' from us.
Expand Down
43 changes: 43 additions & 0 deletions src/ballistica/classic/python/methods/python_methods_classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ballistica/shared/python/python.h"
#include "ballistica/shared/python/python_command.h"
#include "ballistica/shared/python/python_sys.h"
#include "ballistica/ui_v1/widget/root_widget.h"

namespace ballistica::classic {

Expand Down Expand Up @@ -289,6 +290,47 @@ static PyMethodDef PyClassicAppModeDeactivateDef = {
"(internal)\n",
};

// -------------------------- set_root_ui_values -------------------------------

static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* {
BA_PYTHON_TRY;

const char* tickets_text;
const char* tokens_text;
const char* league_rank_text;
static const char* kwlist[] = {"tickets_text", "tokens_text",
"league_rank_text", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "sss",
const_cast<char**>(kwlist), &tickets_text,
&tokens_text, &league_rank_text)) {
return nullptr;
}
BA_PRECONDITION(g_base->InLogicThread());

auto* appmode = ClassicAppMode::GetActiveOrThrow();

appmode->SetRootUITicketsMeterText(tickets_text);
appmode->SetRootUITokensMeterText(tokens_text);
appmode->SetRootUILeagueRankText(league_rank_text);

Py_RETURN_NONE;
BA_PYTHON_CATCH;
}

static PyMethodDef PySetRootUIValuesDef = {
"set_root_ui_values", // name
(PyCFunction)PySetRootUIValues, // method
METH_VARARGS | METH_KEYWORDS, // flags

"set_root_ui_values(tickets_text: str,\n"
" tokens_text: str,\n"
" league_rank_text: str,\n"
") -> None\n"
"\n"
"(internal)",
};

// -----------------------------------------------------------------------------

auto PythonMethodsClassic::GetMethods() -> std::vector<PyMethodDef> {
Expand All @@ -299,6 +341,7 @@ auto PythonMethodsClassic::GetMethods() -> std::vector<PyMethodDef> {
PyClassicAppModeHandleAppIntentDefaultDef,
PyClassicAppModeActivateDef,
PyClassicAppModeDeactivateDef,
PySetRootUIValuesDef,
};
}

Expand Down
Loading

0 comments on commit a78dc70

Please sign in to comment.