-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
804e5e5
commit e46997e
Showing
6 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Copyright Neil McGill, [email protected] | ||
// | ||
|
||
#pragma once | ||
|
||
void wid_rightbar_fini(void); | ||
bool wid_rightbar_init(void); | ||
bool wid_rightbar_ascii_create(void); | ||
|
||
#include "my_wid.hpp" | ||
|
||
// | ||
// Global widgets. | ||
// | ||
extern Widp wid_rightbar_window; | ||
extern Widp wid_map_mini; | ||
extern Widp wid_rightbar; | ||
|
||
extern bool is_mouse_over_rightbar(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// Copyright Neil McGill, [email protected] | ||
// | ||
|
||
#include "my_game.hpp" | ||
#include "my_sdl_event.hpp" | ||
#include "my_string.hpp" | ||
#include "my_thing.hpp" | ||
#include "my_ui.hpp" | ||
#include "my_wid_popup.hpp" | ||
#include "my_wid_popups.hpp" | ||
#include "my_wid_rightbar.hpp" | ||
|
||
static bool wid_rightbar_create(void); | ||
|
||
Widp wid_rightbar {}; | ||
Widp wid_map_mini {}; | ||
|
||
static WidPopup *wid_rightbar_popup; | ||
|
||
void wid_rightbar_fini(void) | ||
{ | ||
TRACE_AND_INDENT(); | ||
wid_destroy(&wid_rightbar); | ||
wid_destroy(&wid_map_mini); | ||
|
||
delete wid_rightbar_popup; | ||
wid_rightbar_popup = nullptr; | ||
} | ||
|
||
bool wid_rightbar_init(void) | ||
{ | ||
TRACE_AND_INDENT(); | ||
return wid_rightbar_create(); | ||
} | ||
|
||
bool wid_rightbar_create(void) | ||
{ | ||
wid_rightbar_fini(); | ||
|
||
auto level = game->level; | ||
if (! level) { | ||
return false; | ||
} | ||
|
||
return wid_rightbar_ascii_create(); | ||
} | ||
|
||
bool is_mouse_over_rightbar(void) | ||
{ | ||
if (! wid_rightbar) { | ||
return false; | ||
} | ||
|
||
// | ||
// If we are in the portion of the lower screen above the itembar | ||
// then do not scroll | ||
// | ||
int x = sdl.mouse_x; | ||
int y = sdl.mouse_y; | ||
pixel_to_ascii(&x, &y); | ||
|
||
static int tlx, tly, brx, bry, cached; | ||
if (cached != TERM_HEIGHT) { | ||
cached = TERM_HEIGHT; | ||
} | ||
|
||
wid_get_tl_x_tl_y_br_x_br_y(wid_rightbar, &tlx, &tly, &brx, &bry); | ||
|
||
// | ||
// Add some border | ||
// | ||
tlx -= 1; | ||
brx++; | ||
tly -= 1; | ||
bry++; | ||
|
||
if ((x >= tlx) && (x < brx) && (y >= tly)) { | ||
// CON(" rightbar %d %d %d", tlx, brx, x); | ||
return true; | ||
} | ||
// CON("NOT rightbar %d %d %d", tlx, brx, x); | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// Copyright Neil McGill, [email protected] | ||
// | ||
|
||
#include "my_color_defs.hpp" | ||
#include "my_game.hpp" | ||
#include "my_level.hpp" | ||
#include "my_level_data.hpp" | ||
#include "my_ptrcheck.hpp" | ||
#include "my_string.hpp" | ||
#include "my_thing.hpp" | ||
#include "my_ui.hpp" | ||
#include "my_vector_bounds_check.hpp" | ||
#include "my_wid_rightbar.hpp" | ||
|
||
bool wid_rightbar_ascii_create(void) | ||
{ | ||
TRACE_AND_INDENT(); | ||
DBG2("Remake rightbar"); | ||
|
||
auto level = game->level; | ||
if (! level) { | ||
return false; | ||
} | ||
|
||
int width = UI_RIGHTBAR_WIDTH; | ||
int y_at = 0; | ||
|
||
{ | ||
TRACE_AND_INDENT(); | ||
point tl = make_point(TERM_WIDTH - width, 0); | ||
point br = make_point(TERM_WIDTH - 1, TERM_HEIGHT - 1); | ||
|
||
wid_rightbar = wid_new_square_window("wid rightbar"); | ||
wid_set_ignore_scroll_events(wid_rightbar, true); | ||
wid_set_pos(wid_rightbar, tl, br); | ||
wid_set_style(wid_rightbar, UI_WID_STYLE_SOLID_NONE); | ||
wid_set_shape_none(wid_rightbar); | ||
wid_lower(wid_rightbar); | ||
} | ||
|
||
{ | ||
TRACE_AND_INDENT(); | ||
auto w = wid_new_square_button(wid_rightbar, "level no"); | ||
point tl = make_point(0, y_at); | ||
point br = make_point(width - 1, y_at); | ||
auto s = dynprintf("Level %u", level->data->num); | ||
wid_set_pos(w, tl, br); | ||
wid_set_text(w, s); | ||
wid_set_style(w, UI_WID_STYLE_NORMAL); | ||
wid_set_shape_none(w); | ||
myfree(s); | ||
} | ||
|
||
{ | ||
y_at++; | ||
TRACE_AND_INDENT(); | ||
auto w = wid_new_plain(wid_rightbar, "Seed"); | ||
point tl = make_point(0, y_at); | ||
point br = make_point(width - 1, y_at); | ||
|
||
auto s = dynprintf("%%fg=gray$%s", game->seed_name.c_str()); | ||
wid_set_pos(w, tl, br); | ||
wid_set_text(w, s); | ||
wid_set_shape_none(w); | ||
myfree(s); | ||
} | ||
|
||
wid_update(wid_rightbar); | ||
|
||
DBG2("Remade rightbar"); | ||
|
||
return true; | ||
} |