Skip to content

Commit

Permalink
added close button to dev console
Browse files Browse the repository at this point in the history
  • Loading branch information
efroemling committed Oct 20, 2024
1 parent 676ebdc commit 4689dfa
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 33 deletions.
56 changes: 28 additions & 28 deletions .efrocachemap

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

4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.7.37 (build 22044, api 9, 2024-10-19)
### 1.7.37 (build 22045, api 9, 2024-10-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 Expand Up @@ -132,6 +132,8 @@
SDL_JoystickOpen() returns nullptr for whatever reason.
- (build 22028) Fixed a longstanding issue that could cause logic thread
bg-dynamics message overflows.
- Added a close button to the dev-console as an alternate to using key presses
to close it.

### 1.7.36 (build 21944, api 8, 2024-07-26)
- Wired up Tokens, BombSquad's new purchasable currency. The first thing these
Expand Down
2 changes: 1 addition & 1 deletion config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cpplint==2.0.0
dmgbuild==1.6.2
filelock==3.16.1
furo==2024.8.6
mypy==1.12.0
mypy==1.12.1
pbxproj==4.2.1
pdoc==15.0.0
pur==7.3.2
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 = 22044
TARGET_BALLISTICA_BUILD = 22045
TARGET_BALLISTICA_VERSION = '1.7.37'


Expand Down
26 changes: 25 additions & 1 deletion src/ballistica/base/ui/dev_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,23 @@ DevConsole::DevConsole() {

void DevConsole::OnUIScaleChanged() {
g_base->logic->event_loop()->PushCall([this] {
RefreshCloseButton_();
RefreshTabButtons_();
RefreshTabContents_();
});
}

void DevConsole::RefreshCloseButton_() {
float bs = BaseScale();
float bwidth = 32.0f * bs;
float bheight = 26.0f * bs;
float bscale = 0.6f * bs;
float x = 0.0f;
close_button_ = std::make_unique<TabButton_>(
"×", false, bscale, DevConsoleHAnchor_::kLeft, x, -bheight, bwidth,
bheight, [this] { Dismiss(); });
}

void DevConsole::RefreshTabButtons_() {
// IMPORTANT: This code should always be run in its own top level call and
// never directly from user code. Otherwise we can wind up mucking with
Expand Down Expand Up @@ -525,6 +537,7 @@ void DevConsole::RefreshTabButtons_() {
// Can't muck with UI from code called while iterating through UI.
// So defer it.
g_base->logic->event_loop()->PushCall([this] {
RefreshCloseButton_();
RefreshTabButtons_();
RefreshTabContents_();
});
Expand Down Expand Up @@ -620,6 +633,9 @@ auto DevConsole::HandleMouseDown(int button, float x, float y) -> bool {
// Make sure we don't muck with our UI while we're in here.
auto lock = ScopedUILock_(this);

if (close_button_ && close_button_->HandleMouseDown(x, y - bottom)) {
return true;
}
for (auto&& button : tab_buttons_) {
if (button->HandleMouseDown(x, y - bottom)) {
return true;
Expand Down Expand Up @@ -663,6 +679,10 @@ void DevConsole::HandleMouseUp(int button, float x, float y) {
// Make sure we don't muck with our UI while we're in here.
auto lock = ScopedUILock_(this);

if (close_button_) {
close_button_->HandleMouseUp(x, y - bottom);
}

for (auto&& button : tab_buttons_) {
button->HandleMouseUp(x, y - bottom);
}
Expand Down Expand Up @@ -1130,6 +1150,7 @@ void DevConsole::ToggleState() {
// Can't muck with UI from code (potentially) called while iterating
// through UI. So defer it.
g_base->logic->event_loop()->PushCall([this] {
RefreshCloseButton_();
RefreshTabButtons_();
RefreshTabContents_();
});
Expand Down Expand Up @@ -1240,6 +1261,7 @@ void DevConsole::Draw(FrameDef* frame_def) {
last_virtual_res_y_ = screen_virtual_height;
last_virtual_res_change_time_ = display_time;
g_base->logic->event_loop()->PushCall([this] {
RefreshCloseButton_();
RefreshTabButtons_();
RefreshTabContents_();
});
Expand Down Expand Up @@ -1423,11 +1445,13 @@ void DevConsole::Draw(FrameDef* frame_def) {
}
}

// Tab Buttons.
// Close Button and Tab Buttons.
{
// Make sure we don't muck with our UI while we're in here.
auto lock = ScopedUILock_(this);

close_button_->Draw(pass, bottom);

for (auto&& button : tab_buttons_) {
button->Draw(pass, bottom);
}
Expand Down
3 changes: 3 additions & 0 deletions src/ballistica/base/ui/dev_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define BALLISTICA_BASE_UI_DEV_CONSOLE_H_

#include <list>
#include <memory>
#include <string>
#include <vector>

Expand Down Expand Up @@ -87,6 +88,7 @@ class DevConsole {
auto Bottom_() const -> float;
void SubmitPythonCommand_(const std::string& command);
void InvokeStringEditor_();
void RefreshCloseButton_();
void RefreshTabButtons_();
void RefreshTabContents_();

Expand Down Expand Up @@ -120,6 +122,7 @@ class DevConsole {
PythonRef string_edit_adapter_;
std::list<std::string> input_history_;
std::list<OutputLine_> output_lines_;
std::unique_ptr<Widget_> close_button_;
std::vector<std::unique_ptr<Widget_> > widgets_;
std::vector<std::unique_ptr<Widget_> > tab_buttons_;
Object::Ref<Repeater> key_repeater_;
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 @@ -40,7 +40,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {

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

Expand Down

0 comments on commit 4689dfa

Please sign in to comment.