Interface tweaks, partly thanks to ADoS

- Bottom buttons now have standardized size of 38x38 (one pixel larger than before in both dimensions)
- Padding in terrain screen is now uniform
- Bottom button help pages now match the actual toolbars
- Bottom buttons are now specified in a flexible way which would allow for easily reordering them or making a new mode toolbar
This commit is contained in:
2015-07-28 09:05:08 -04:00
parent 922730d89d
commit 56d4e4455c
8 changed files with 85 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -36,9 +36,7 @@
#include "shop.hpp"
#include "prefs.hpp"
rectangle bottom_buttons[7];
rectangle town_buttons[10];
rectangle combat_buttons[9];
rectangle bottom_buttons[14];
rectangle world_screen = {23, 23, 346, 274};
// TODO: The duplication of rectangle here shouldn't be necessary...
rectangle item_screen_button_rects[9] = {
@@ -176,24 +174,6 @@ void init_screen_locs() {
for(l = 0; l < 48; l++)
univ.out_maps[i][k][l] = 0;
for(i = 0; i < 7; i++) {
bottom_buttons[i].top = 383;
bottom_buttons[i].bottom = 420;
bottom_buttons[i].left = 5 + (i * 37);
bottom_buttons[i].right = bottom_buttons[i].left + 36;
town_buttons[i] = bottom_buttons[i];
}
for(i = 0; i < 5; i++) {
combat_buttons[i] = bottom_buttons[i];
}
town_buttons[7] = bottom_buttons[6];
town_buttons[5] = medium_buttons[0];
town_buttons[6] = medium_buttons[1];
for(i = 5; i < 9; i++) {
combat_buttons[i] = medium_buttons[i - 5];
}
// name, use, give, drip, info, sell/id each one 13 down
item_buttons[0][ITEMBTN_NAME].top = 17;
item_buttons[0][ITEMBTN_NAME].bottom = item_buttons[0][ITEMBTN_NAME].top + 12;
@@ -1041,37 +1021,29 @@ bool handle_action(sf::Event event) {
switch(overall_mode) {
case MODE_OUTDOORS: case MODE_LOOK_OUTDOORS:
cur_loc = univ.party.p_loc;
for(int i = 0; i < 7; i++)
for(int i = 0; i < 14; i++)
if(the_point.in(bottom_buttons[i])) {
button_hit = i;
if(!spell_forced)
main_button_click(bottom_buttons[i]);
main_button_click(i);
}
break;
case MODE_TOWN: case MODE_TALK_TOWN: case MODE_TOWN_TARGET: case MODE_USE_TOWN: case MODE_LOOK_TOWN:
case MODE_DROP_TOWN: case MODE_BASH_TOWN:
case MODE_COMBAT: case MODE_SPELL_TARGET: case MODE_FIRING: case MODE_THROWING:
case MODE_FANCY_TARGET: case MODE_DROP_COMBAT: case MODE_LOOK_COMBAT:
cur_loc = center;
for(int i = 0; i < 8; i++)
if(the_point.in(town_buttons[i])) {
for(int i = 0; i < 14; i++)
if(the_point.in(bottom_buttons[i])) {
button_hit = i;
if(!spell_forced)
main_button_click(town_buttons[i]);
main_button_click(i);
}
break;
case MODE_TALKING: case MODE_SHOPPING: break;
case MODE_COMBAT: case MODE_SPELL_TARGET: case MODE_FIRING: case MODE_THROWING:
case MODE_FANCY_TARGET: case MODE_DROP_COMBAT: case MODE_LOOK_COMBAT:
cur_loc = center;
for(int i = 0; i < 9; i++)
if(the_point.in(combat_buttons[i])) {
button_hit = i;
if(!spell_forced)
main_button_click(combat_buttons[i]);
}
break;
case MODE_STARTUP: case MODE_RESTING: case MODE_CUTSCENE:
// If we get here during these modes, something is probably not right, so bail out
add_string_to_buf("Unexpected game state!");

View File

@@ -74,8 +74,8 @@ long anim_ticks = 0;
// 0 - terrain 1 - buttons 2 - pc stats
// 3 - item stats 4 - text bar 5 - text area (not right)
// TODO: The duplication of rectangle here shouldn't be necessary...
rectangle win_from_rects[6] = {rectangle{0,0,351,279},rectangle{0,0,37,258},rectangle{0,0,115,288},rectangle{0,0,143,288},rectangle{0,0,21,279},rectangle{0,0,0,288}};
rectangle win_to_rects[6] = {rectangle{5,5,356,284},rectangle{383,5,420,263},rectangle{0,0,116,271},rectangle{0,0,144,271},rectangle{358,5,379,284},rectangle{0,0,138,256}};
rectangle win_from_rects[6] = {rectangle{0,0,350,278},rectangle{0,0,37,258},rectangle{0,0,115,288},rectangle{0,0,143,288},rectangle{0,0,21,279},rectangle{0,0,0,288}};
rectangle win_to_rects[6] = {rectangle{5,5,356,284},rectangle{383,5,421,271},rectangle{0,0,116,271},rectangle{0,0,144,271},rectangle{358,5,379,284},rectangle{0,0,138,256}};
// 0 - title 1 - button 2 - credits 3 - base button
rectangle startup_from[4] = {rectangle{0,0,274,602},rectangle{274,0,322,301},rectangle{0,301,67,579},rectangle{274,301,314,341}}; ////
@@ -470,18 +470,16 @@ void draw_start_button(short which_position,short which_button) {
win_draw_string(mainPtr,to_rect,button_labels[which_position],eTextMode::CENTRE,style,ul);
}
void main_button_click(rectangle button_rect) {
button_rect.offset(ul);
void main_button_click(int which_button) {
mainPtr.setActive();
clip_rect(mainPtr, button_rect);
// TODO: Mini-event loop so that the click doesn't happen until releasing the mouse button
draw_buttons(1);
draw_buttons(which_button);
mainPtr.display();
if(play_sounds)
play_sound(37);
else sf::sleep(time_in_ticks(5));
draw_buttons(0);
draw_buttons(-1);
undo_clip(mainPtr);
}
@@ -595,7 +593,7 @@ void redraw_screen(int refresh) {
if(refresh & REFRESH_BAR)
draw_text_bar();
refresh_text_bar();
draw_buttons(0);
draw_buttons(-1);
break;
}
if(overall_mode == MODE_COMBAT)
@@ -648,31 +646,80 @@ void put_background() {
tileImage(mainPtr, rectangle(mainPtr), bg_pict);
}
//mode; // 0 - regular 1 - button action
// mode; -1 - all buttons, normal; otherwise draw this button pressed
void draw_buttons(short mode) {
rectangle source_rect = {0,0,37,258}, dest_rec; bool spec_draw = false;
rectangle lg_rect = {0,0,38,38}, sm_rect[2] = {{0,38,19,76}, {19,38,38,76}}, dest_rec;
static const int MAX_TOOLBAR_BUTTONS = 14;
static const location null_loc(-1,-1);
static const location out_buttons[MAX_TOOLBAR_BUTTONS] = {
{0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {5,1}, null_loc, null_loc, null_loc, null_loc, null_loc, null_loc, null_loc
};
static const location town_buttons[MAX_TOOLBAR_BUTTONS] = {
{0,0}, {1,0}, {2,0}, {2,1}, {3,1}, {4,2}, {5,2}, {4,1}, null_loc, null_loc, null_loc, null_loc, null_loc, null_loc
};
static const location combat_buttons[MAX_TOOLBAR_BUTTONS] = {
{0,0}, {1,0}, {2,0}, {0,1}, {1,1}, {0,2}, {2,2}, {1,2}, {3,2}, null_loc, null_loc, null_loc, null_loc, null_loc
};
extern rectangle bottom_buttons[MAX_TOOLBAR_BUTTONS];
if(mode == 1) {
spec_draw = true;
mode -= 100;
auto& toolbar = is_combat() ? combat_buttons : (is_town() ? town_buttons : out_buttons);
static bool inited = false;
static sf::RenderTexture button_gw;
if(!inited) {
inited = true;
button_gw.create(266,38);
}
if(is_combat()) { // TODO: Draw buttons one at a time instead of singly
source_rect.top += 37;
source_rect.bottom += 37;
}
if(is_town()) {
source_rect.top += 74;
source_rect.bottom += 74;
dest_rec = lg_rect;
bool bottom_half = false;
std::fill_n(bottom_buttons, MAX_TOOLBAR_BUTTONS, rectangle());
for(int i = 0; i < MAX_TOOLBAR_BUTTONS && toolbar[i] != null_loc; i++) {
rectangle source_rect = {0, 0, 32, 32};
rectangle to_rect = dest_rec, btn_rect, icon_rect;
source_rect.offset(32 * toolbar[i].x, 38 + 32 * toolbar[i].y);
if(toolbar[i].y == 2) {
// Small button
btn_rect = sm_rect[bottom_half];
source_rect.height() = 13;
to_rect.height() = 19;
if(bottom_half) {
to_rect.offset(0,19);
bottom_half = false;
} else bottom_half = true;
icon_rect = {3,3,13,13};
} else {
// Large button
btn_rect = lg_rect;
if(bottom_half) {
dest_rec.offset(38,0);
bottom_half = false;
}
icon_rect = {3,3,32,32};
}
if(mode == -1) {
rect_draw_some_item(buttons_gworld, btn_rect, button_gw, to_rect);
to_rect.inset(3,3);
rect_draw_some_item(buttons_gworld, source_rect, button_gw, to_rect, sf::BlendAlpha);
to_rect.inset(-3,-3);
}
to_rect.offset(win_to_rects[1].topLeft());
to_rect.offset(ul);
if(i == mode)
fill_rect(mainPtr, to_rect, sf::Color::Blue);
else fill_rect(mainPtr, to_rect, sf::Color::Black);
bottom_buttons[i] = to_rect;
if(toolbar[i].y != 2 || !bottom_half) {
dest_rec.offset(38,0);
bottom_half = false;
}
}
button_gw.display();
dest_rec = win_to_rects[1];
dest_rec.offset(ul);
if(spec_draw)
fill_rect(mainPtr, dest_rec, sf::Color::Blue);
else fill_rect(mainPtr, dest_rec, sf::Color::Black);
rect_draw_some_item(buttons_gworld, source_rect, mainPtr, dest_rec, sf::BlendAdd);
rect_draw_some_item(button_gw.getTexture(), rectangle(button_gw), mainPtr, dest_rec, sf::BlendAdd);
}
void draw_text_bar() {
@@ -1559,10 +1606,10 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
void draw_pointing_arrows() {
// TODO: The duplication of rectangle here shouldn't be necessary...
rectangle sources[4] = {
rectangle{352,28,360,36}, // up
rectangle{352,10,360,18}, // left
rectangle{352,01,360,9}, // down
rectangle{352,19,360,27} // right
rectangle{351,28,359,36}, // up
rectangle{351,10,359,18}, // left
rectangle{351,01,359,9}, // down
rectangle{351,19,359,27} // right
};
rectangle dests[8] = {rectangle{7,100,15,108},rectangle{7,170,15,178},rectangle{140,7,148,15},rectangle{212,7,220,15},
rectangle{346,100,354,108},rectangle{346,170,354,178},rectangle{140,274,148,282},rectangle{212,274,220,282}};

View File

@@ -28,7 +28,7 @@ void draw_startup(short but_type);
void draw_anim();
void place_anim();
void draw_start_button(short which_position,short which_button);
void main_button_click(rectangle button_rect);
void main_button_click(int which_button);
void arrow_button_click(rectangle button_rect);
void end_startup();
void Set_up_win ();