Refactor rendering to use an SFML view for placing the main UI within the overall interface
This commit is contained in:
@@ -203,11 +203,15 @@ bool cControl::handleClick(location){
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
clicked = frame.contains(e.mouseButton.x, e.mouseButton.y);
|
||||
location clickPos(e.mouseButton.x, e.mouseButton.y);
|
||||
clickPos = inWindow->mapPixelToCoords(clickPos);
|
||||
clicked = frame.contains(clickPos);
|
||||
depressed = false;
|
||||
} else if(e.type == sf::Event::MouseMoved){
|
||||
restore_cursor();
|
||||
depressed = frame.contains(e.mouseMove.x, e.mouseMove.y);
|
||||
location toPos(e.mouseMove.x, e.mouseMove.y);
|
||||
toPos = inWindow->mapPixelToCoords(toPos);
|
||||
depressed = frame.contains(toPos);
|
||||
}
|
||||
}
|
||||
if(get_bool_pref("PlaySounds", true)) {
|
||||
|
||||
@@ -146,6 +146,7 @@ bool cTextField::handleClick(location clickLoc) {
|
||||
} else if(e.type == sf::Event::MouseMoved){
|
||||
restore_cursor();
|
||||
location newLoc(e.mouseMove.x, e.mouseMove.y);
|
||||
newLoc = inWindow->mapPixelToCoords(newLoc);
|
||||
set_ip(newLoc, &cTextField::selectionPoint);
|
||||
if(is_double) {
|
||||
if(selectionPoint > initial_ip) {
|
||||
|
||||
@@ -111,11 +111,14 @@ bool cScrollbar::handleClick(location where) {
|
||||
while(!done){
|
||||
redraw();
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
sf::Vector2i mouseLoc = sf::Mouse::getPosition(*inWindow);
|
||||
location mouseLoc = sf::Mouse::getPosition(*inWindow);
|
||||
mouseLoc = inWindow->mapPixelToCoords(mouseLoc);
|
||||
int mousePos = vert ? mouseLoc.y : mouseLoc.x;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
clicked = frame.contains(e.mouseButton.x, e.mouseButton.y);
|
||||
location clickLoc(e.mouseButton.x, e.mouseButton.y);
|
||||
clickLoc = inWindow->mapPixelToCoords(clickLoc);
|
||||
clicked = frame.contains(clickLoc);
|
||||
depressed = false;
|
||||
switch(pressedPart) {
|
||||
case PART_UP: pos--; break;
|
||||
@@ -147,7 +150,9 @@ bool cScrollbar::handleClick(location where) {
|
||||
depressed = mousePos >= bar_end - btn_size;
|
||||
break;
|
||||
}
|
||||
if(pressedPart != PART_THUMB && !frame.contains(e.mouseMove.x, e.mouseMove.y)) depressed = false;
|
||||
location toLoc(e.mouseMove.x, e.mouseMove.y);
|
||||
toLoc = inWindow->mapPixelToCoords(toLoc);
|
||||
if(pressedPart != PART_THUMB && !frame.contains(toLoc)) depressed = false;
|
||||
}
|
||||
pos = minmax(0,max,pos);
|
||||
if(parent && !link.empty())
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "render_shapes.hpp"
|
||||
|
||||
rectangle bottom_buttons[14];
|
||||
rectangle world_screen = {23, 23, 346, 274};
|
||||
rectangle item_screen_button_rects[9] = {
|
||||
{125,10,141,28},{125,40,141,58},{125,68,141,86},{125,98,141,116},{125,126,141,144},{125,156,141,174},
|
||||
{126,176,141,211},
|
||||
@@ -60,6 +59,7 @@ rectangle pc_buttons[6][5];
|
||||
// name, hp, sp, info, trade
|
||||
|
||||
extern rectangle startup_button[6];
|
||||
extern rectangle win_to_rects[6];
|
||||
extern bool flushingInput;
|
||||
extern bool fog_lifted;
|
||||
extern bool cartoon_happening;
|
||||
@@ -69,7 +69,7 @@ bool item_area_button_active[8][6];
|
||||
bool pc_area_button_active[6][5];
|
||||
short item_bottom_button_active[9] = {0,0,0,0,0, 0,1,1,1};
|
||||
|
||||
rectangle pc_help_button,pc_area_rect,item_area_rect;
|
||||
rectangle pc_help_button;
|
||||
|
||||
short current_terrain_type = 0,num_out_moves = 0;
|
||||
short store_drop_item;
|
||||
@@ -85,6 +85,7 @@ extern eGameMode overall_mode;
|
||||
extern location to_create;
|
||||
extern bool All_Done,spell_forced,monsters_going;
|
||||
extern bool party_in_memory;
|
||||
extern sf::View mainView;
|
||||
|
||||
// game info globals
|
||||
extern sf::RenderWindow mainPtr;
|
||||
@@ -107,7 +108,6 @@ extern eStatMode stat_screen_mode;
|
||||
extern bool map_visible;
|
||||
extern sf::RenderWindow mini_map;
|
||||
|
||||
extern location ul;
|
||||
extern std::shared_ptr<cScrollbar> text_sbar,item_sbar,shop_sbar;
|
||||
extern short shop_identify_cost;
|
||||
|
||||
@@ -128,7 +128,7 @@ bool current_bash_is_bash = false;
|
||||
extern void edit_stuff_done();
|
||||
|
||||
void init_screen_locs() {
|
||||
rectangle startup_base = {279,5,327,306};
|
||||
rectangle startup_base = {281,1,329,302};
|
||||
rectangle shop_base = {63,12,99,267};
|
||||
|
||||
for(short i = 0; i < 7; i++)
|
||||
@@ -155,11 +155,11 @@ void init_screen_locs() {
|
||||
|
||||
for(short i = 0; i < 6; i++) {
|
||||
startup_button[i] = startup_base;
|
||||
startup_button[i].offset(301 * (i / 3) - 18,48 * (i % 3));
|
||||
startup_button[i].offset(301 * (i / 3), 48 * (i % 3));
|
||||
}
|
||||
startup_top.top = 5;
|
||||
startup_top.top = 7;
|
||||
startup_top.bottom = startup_button[STARTBTN_LOAD].top;
|
||||
startup_top.left = 5;
|
||||
startup_top.left = startup_base.left;
|
||||
startup_top.right = startup_button[STARTBTN_JOIN].right;
|
||||
|
||||
// name, use, give, drip, info, sell/id each one 13 down
|
||||
@@ -229,20 +229,6 @@ void init_screen_locs() {
|
||||
pc_help_button.bottom = 114;
|
||||
pc_help_button.left = 251;
|
||||
pc_help_button.right = 267;
|
||||
|
||||
pc_area_rect.top = PC_WIN_UL_Y;
|
||||
pc_area_rect.left = PC_WIN_UL_X;
|
||||
pc_area_rect.bottom = PC_WIN_UL_Y + 116;
|
||||
pc_area_rect.right = PC_WIN_UL_X + 271;
|
||||
item_area_rect.top = ITEM_WIN_UL_Y;
|
||||
item_area_rect.left = ITEM_WIN_UL_X;
|
||||
item_area_rect.bottom = ITEM_WIN_UL_Y + 143;
|
||||
item_area_rect.right = ITEM_WIN_UL_X + 271;
|
||||
|
||||
extern rectangle win_to_rects[6];
|
||||
win_to_rects[5].offset(TEXT_WIN_UL_X,TEXT_WIN_UL_Y);
|
||||
win_to_rects[2].offset(PC_WIN_UL_X,PC_WIN_UL_Y);
|
||||
win_to_rects[3].offset(ITEM_WIN_UL_X,ITEM_WIN_UL_Y);
|
||||
}
|
||||
|
||||
bool prime_time() {
|
||||
@@ -984,11 +970,14 @@ bool handle_action(sf::Event event) {
|
||||
short button_hit = 12;
|
||||
bool right_button = event.mouseButton.button == sf::Mouse::Right;
|
||||
eGameMode previous_mode;
|
||||
rectangle world_screen = win_to_rects[WINRECT_TERVIEW];
|
||||
world_screen.inset(13, 13);
|
||||
|
||||
std::ostringstream str;
|
||||
location the_point,point_in_area;
|
||||
|
||||
the_point = location(event.mouseButton.x, event.mouseButton.y);
|
||||
the_point = mainPtr.mapPixelToCoords(the_point, mainView);
|
||||
end_scenario = false;
|
||||
|
||||
// MARK: First, figure out where party is
|
||||
@@ -1024,9 +1013,6 @@ bool handle_action(sf::Event event) {
|
||||
return are_done;
|
||||
}
|
||||
|
||||
the_point.x -= ul.x;
|
||||
the_point.y -= ul.y;
|
||||
|
||||
// Now split off the extra stuff, like talking and shopping.
|
||||
if(overall_mode == MODE_TALKING) {
|
||||
handle_talk_event(the_point);
|
||||
@@ -1132,8 +1118,8 @@ bool handle_action(sf::Event event) {
|
||||
|
||||
// MARK: Begin: click in terrain
|
||||
if(the_point.in(world_screen) && (is_out() || is_town() || is_combat())){
|
||||
int i = (the_point.x - 23) / 28;
|
||||
int j = (the_point.y - 23) / 36;
|
||||
int i = (the_point.x - 32) / 28;
|
||||
int j = (the_point.y - 20) / 36;
|
||||
location destination = cur_loc;
|
||||
|
||||
// Check for quick look
|
||||
@@ -1247,14 +1233,15 @@ bool handle_action(sf::Event event) {
|
||||
// MARK: End: Screen shift
|
||||
|
||||
// MARK: Process clicks in PC stats area
|
||||
if(the_point.in(pc_area_rect)) {
|
||||
if(the_point.in(win_to_rects[WINRECT_PCSTATS])) {
|
||||
location pc_win_ul = win_to_rects[WINRECT_PCSTATS].topLeft();
|
||||
point_in_area = the_point;
|
||||
point_in_area.x -= PC_WIN_UL_X;
|
||||
point_in_area.y -= PC_WIN_UL_Y;
|
||||
point_in_area.x -= pc_win_ul.x;
|
||||
point_in_area.y -= pc_win_ul.y;
|
||||
if(point_in_area.in(pc_help_button)) {
|
||||
pc_help_button.offset(PC_WIN_UL_X,PC_WIN_UL_Y);
|
||||
arrow_button_click(pc_help_button);
|
||||
pc_help_button.offset(-PC_WIN_UL_X,-PC_WIN_UL_Y);
|
||||
rectangle help_button = pc_help_button;
|
||||
help_button.offset(pc_win_ul);
|
||||
arrow_button_click(help_button);
|
||||
cChoiceDlog("help-party").show();
|
||||
}
|
||||
for(int i = 0; i < 6; i++)
|
||||
@@ -1262,9 +1249,9 @@ bool handle_action(sf::Event event) {
|
||||
if(pc_area_button_active[i][j] && point_in_area.in(pc_buttons[i][j])) {
|
||||
if((j == 1 || j == 2) && !univ.party[i].is_alive())
|
||||
break;
|
||||
pc_buttons[i][j].offset(PC_WIN_UL_X,PC_WIN_UL_Y);
|
||||
arrow_button_click(pc_buttons[i][j]);
|
||||
pc_buttons[i][j].offset(-PC_WIN_UL_X,-PC_WIN_UL_Y);
|
||||
rectangle button_rect = pc_buttons[i][j];
|
||||
button_rect.offset(pc_win_ul);
|
||||
arrow_button_click(button_rect);
|
||||
switch(j) {
|
||||
case 0:
|
||||
handle_switch_pc(i, need_redraw);
|
||||
@@ -1306,16 +1293,17 @@ bool handle_action(sf::Event event) {
|
||||
}
|
||||
|
||||
// Process clicks in item stats area
|
||||
if(the_point.in(item_area_rect)) {
|
||||
if(the_point.in(win_to_rects[WINRECT_INVEN])) {
|
||||
location item_win_ul = win_to_rects[WINRECT_INVEN].topLeft();
|
||||
point_in_area = the_point;
|
||||
point_in_area.x -= ITEM_WIN_UL_X;
|
||||
point_in_area.y -= ITEM_WIN_UL_Y;
|
||||
point_in_area.x -= item_win_ul.x;
|
||||
point_in_area.y -= item_win_ul.y;
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
if(item_bottom_button_active[i] > 0 && point_in_area.in(item_screen_button_rects[i])) {
|
||||
item_screen_button_rects[i].offset(ITEM_WIN_UL_X,ITEM_WIN_UL_Y);
|
||||
arrow_button_click(item_screen_button_rects[i]);
|
||||
item_screen_button_rects[i].offset(-ITEM_WIN_UL_X,-ITEM_WIN_UL_Y);
|
||||
rectangle button_rect = item_screen_button_rects[i];
|
||||
button_rect.offset(item_win_ul);
|
||||
arrow_button_click(button_rect);
|
||||
switch(i) {
|
||||
case 6: // special screen
|
||||
give_help(50,0);
|
||||
@@ -1336,9 +1324,9 @@ bool handle_action(sf::Event event) {
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(int j = 0; j < 6; j++)
|
||||
if(item_area_button_active[i][j] && point_in_area.in(item_buttons[i][j])) {
|
||||
item_buttons[i][j].offset(ITEM_WIN_UL_X,ITEM_WIN_UL_Y);
|
||||
arrow_button_click(item_buttons[i][j]);
|
||||
item_buttons[i][j].offset(-ITEM_WIN_UL_X,-ITEM_WIN_UL_Y);
|
||||
rectangle button_rect = item_buttons[i][j];
|
||||
button_rect.offset(item_win_ul);
|
||||
arrow_button_click(button_rect);
|
||||
|
||||
item_hit = item_sbar->getPosition() + i;
|
||||
switch(j) {
|
||||
@@ -1541,8 +1529,9 @@ void handle_menu_spell(eSpell spell_picked) {
|
||||
pass_point.x = bottom_buttons[1].left + 5;
|
||||
pass_point.y = bottom_buttons[1].top + 5;
|
||||
}
|
||||
event.mouseButton.x = pass_point.x + ul.x;
|
||||
event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
event.mouseButton.x = pass_point.x;
|
||||
event.mouseButton.y = pass_point.y;
|
||||
handle_action(event);
|
||||
}
|
||||
|
||||
@@ -1651,8 +1640,9 @@ bool handle_keystroke(sf::Event& event){
|
||||
for(short i = 0; i < 9; i++)
|
||||
if(chr2 == talk_chars[i] && (!talk_end_forced || i == 6 || i == 5)) {
|
||||
int j = talk_end_forced ? i - 5 : i;
|
||||
pass_point.x = talk_words[j].rect.left + 9 + ul.x;
|
||||
pass_point.y = talk_words[j].rect.top + 9 + ul.y;
|
||||
pass_point = talk_words[j].rect.topLeft();
|
||||
pass_point.x += 9; pass_point.y += 9;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -1665,8 +1655,9 @@ bool handle_keystroke(sf::Event& event){
|
||||
}
|
||||
for(short i = 0; i < 8; i++)
|
||||
if(chr2 == shop_chars[i]) {
|
||||
pass_point.x = shopping_rects[i][SHOPRECT_ACTIVE_AREA].left + 9 + ul.x;
|
||||
pass_point.y = shopping_rects[i][SHOPRECT_ACTIVE_AREA].top + 9 + ul.y;
|
||||
pass_point = shopping_rects[i][SHOPRECT_ACTIVE_AREA].topLeft();
|
||||
pass_point.x += 9; pass_point.y += 9;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -1678,8 +1669,7 @@ bool handle_keystroke(sf::Event& event){
|
||||
chr2 = kb::Z;
|
||||
}
|
||||
else {
|
||||
pass_point.x = terrain_click[i].x + ul.x;
|
||||
pass_point.y = terrain_click[i].y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel(terrain_click[i], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -1727,24 +1717,30 @@ bool handle_keystroke(sf::Event& event){
|
||||
break;
|
||||
|
||||
case '1': case '2': case '3': case '4': case '5': case '6':
|
||||
pass_point.x = pc_buttons[((short) chr) - 49][0].left + 1 + PC_WIN_UL_X + ul.x;
|
||||
pass_point.y = pc_buttons[((short) chr) - 49][0].top + PC_WIN_UL_Y + ul.y;
|
||||
pass_point = pc_buttons[((short) chr) - 49][0].topLeft();
|
||||
pass_point.x += 1 + win_to_rects[WINRECT_PCSTATS].left;
|
||||
pass_point.y += win_to_rects[WINRECT_PCSTATS].top;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
break;
|
||||
|
||||
case '9': // Special items
|
||||
pass_point.x = item_screen_button_rects[6].left + ITEM_WIN_UL_X + ul.x;
|
||||
pass_point.y = item_screen_button_rects[6].top + ITEM_WIN_UL_Y + ul.y;
|
||||
pass_point = item_screen_button_rects[6].topLeft();
|
||||
pass_point.x += win_to_rects[WINRECT_INVEN].left;
|
||||
pass_point.y += win_to_rects[WINRECT_INVEN].top;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
break;
|
||||
|
||||
case '0': // Jobs/quests
|
||||
pass_point.x = item_screen_button_rects[7].left + ITEM_WIN_UL_X + ul.x;
|
||||
pass_point.y = item_screen_button_rects[7].top + ITEM_WIN_UL_Y + ul.y;
|
||||
pass_point = item_screen_button_rects[7].topLeft();
|
||||
pass_point.x += win_to_rects[WINRECT_INVEN].left;
|
||||
pass_point.y += win_to_rects[WINRECT_INVEN].top;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -1754,17 +1750,16 @@ bool handle_keystroke(sf::Event& event){
|
||||
if(overall_mode == MODE_FANCY_TARGET) { // cast multi-target spell, set # targets to 0 so that
|
||||
// space clicked doesn't matter
|
||||
num_targets_left = 0;
|
||||
pass_point = terrain_click[5];
|
||||
pass_event.mouseButton.x = pass_point.x + ul.x;
|
||||
pass_event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel(terrain_click[5], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
} else if(overall_mode == MODE_SPELL_TARGET)
|
||||
// Rotate a force wall
|
||||
spell_cast_hit_return();
|
||||
else if(overall_mode == MODE_TOWN || overall_mode == MODE_COMBAT || overall_mode == MODE_OUTDOORS) {
|
||||
// Pause (skip turn)
|
||||
pass_point.x = terrain_click[5].x + ul.x;
|
||||
pass_point.y = terrain_click[5].y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel(terrain_click[5], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -2032,36 +2027,33 @@ bool handle_keystroke(sf::Event& event){
|
||||
break;
|
||||
case 'a': // Show automap
|
||||
if(overall_mode < MODE_TALK_TOWN) {
|
||||
pass_point.x = (overall_mode == MODE_OUTDOORS) ? 180 : 221;
|
||||
pass_point.y = 405;
|
||||
pass_event.mouseButton.x = pass_point.x + ul.x;
|
||||
pass_event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel({overall_mode == MODE_OUTDOORS ? 180 : 221, 405}, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u': // Use space
|
||||
if(overall_mode == MODE_TOWN || overall_mode == MODE_USE_TOWN) {
|
||||
pass_point.x = 220;
|
||||
pass_point.y = 388;
|
||||
pass_event.mouseButton.x = pass_point.x + ul.x;
|
||||
pass_event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel({220, 388}, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b': case 'L': // Bash door, pick lock
|
||||
if(overall_mode == MODE_TOWN || overall_mode == MODE_BASH_TOWN) {
|
||||
pass_point.x = chr == 'b' ? 1002 : 1003;
|
||||
pass_point.y = 0;
|
||||
pass_event.mouseButton.x = pass_point.x + ul.x;
|
||||
pass_event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel({chr == 'b' ? 1002 : 1003, 0}, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
}
|
||||
|
||||
case 'A': // Alchemy
|
||||
if(overall_mode == MODE_TOWN) {
|
||||
pass_point.x = 1000 + ul.x;
|
||||
pass_point = mainPtr.mapCoordsToPixel({1000, 0}, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -2101,7 +2093,7 @@ bool handle_keystroke(sf::Event& event){
|
||||
if(overall_mode == MODE_COMBAT)
|
||||
btn = 5;
|
||||
else if(overall_mode == MODE_TOWN) {
|
||||
pass_point.x = 1001 + ul.x;
|
||||
pass_point = mainPtr.mapCoordsToPixel({1001, 0}, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
@@ -2142,8 +2134,9 @@ bool handle_keystroke(sf::Event& event){
|
||||
if(btn < 50) {
|
||||
pass_point.x = bottom_buttons[btn].left + 5;
|
||||
pass_point.y = bottom_buttons[btn].top + 5;
|
||||
pass_event.mouseButton.x = pass_point.x + ul.x;
|
||||
pass_event.mouseButton.y = pass_point.y + ul.y;
|
||||
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event);
|
||||
}
|
||||
break;
|
||||
@@ -2154,12 +2147,13 @@ bool handle_keystroke(sf::Event& event){
|
||||
|
||||
bool handle_scroll(sf::Event& event) {
|
||||
rectangle status_panel_rect = {0,0,144,271}, text_panel_rect = {0,0,138,271};
|
||||
status_panel_rect.offset(ul);
|
||||
status_panel_rect.offset(ITEM_WIN_UL_X,ITEM_WIN_UL_Y);
|
||||
text_panel_rect.offset(ul);
|
||||
text_panel_rect.offset(TEXT_WIN_UL_X,TEXT_WIN_UL_Y);
|
||||
rectangle world_screen = win_to_rects[WINRECT_TERVIEW];
|
||||
world_screen.inset(13, 13);
|
||||
status_panel_rect.offset(win_to_rects[WINRECT_INVEN].topLeft());
|
||||
text_panel_rect.offset(win_to_rects[WINRECT_TRANSCRIPT].topLeft());
|
||||
fill_rect(mainPtr, world_screen, sf::Color::Magenta);
|
||||
location pos(event.mouseWheel.x, event.mouseWheel.y);
|
||||
pos = mainPtr.mapPixelToCoords(pos, mainView);
|
||||
int amount = event.mouseWheel.delta;
|
||||
if(item_sbar->isVisible() && pos.in(status_panel_rect)) {
|
||||
item_sbar->setPosition(item_sbar->getPosition() - amount);
|
||||
|
||||
@@ -114,4 +114,12 @@ const int PCBTN_TRADE = 4;
|
||||
const int ITEM_WIN_SPECIAL = 6;
|
||||
const int ITEM_WIN_QUESTS = 7;
|
||||
|
||||
// Gobal window rects
|
||||
const int WINRECT_TERVIEW = 0;
|
||||
const int WINRECT_ACTBTNS = 1;
|
||||
const int WINRECT_PCSTATS = 2;
|
||||
const int WINRECT_INVEN = 3;
|
||||
const int WINRECT_STATUS = 4;
|
||||
const int WINRECT_TRANSCRIPT = 5;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,6 @@ extern short stat_window;
|
||||
extern eGameMode overall_mode;
|
||||
extern bool changed_display_mode;
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern location ul;
|
||||
extern rectangle d_rects[80];
|
||||
extern short d_rect_index[80];
|
||||
extern eStatMode stat_screen_mode;
|
||||
@@ -67,7 +66,7 @@ short store_personality,store_personality_graphic,shop_identify_cost;
|
||||
std::string save_talk_str1, save_talk_str2;
|
||||
sf::RenderTexture talk_gworld;
|
||||
bool talk_end_forced;
|
||||
rectangle talk_area_rect = {5,5,420,284}, word_place_rect = {44,7,372,257},talk_help_rect = {5,254,21,272};
|
||||
rectangle talk_area_rect = {7,19,422,298}, word_place_rect = {44,7,372,257},talk_help_rect = {7,268,23,286};
|
||||
std::string title_string;
|
||||
mon_num_t store_monst_type;
|
||||
short store_m_num;
|
||||
@@ -206,16 +205,14 @@ void handle_shop_event(location p) {
|
||||
unsigned long store_what_picked;
|
||||
|
||||
if(p.in(talk_help_rect)) {
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(!help_btn->handleClick(loc))
|
||||
if(!help_btn->handleClick(p))
|
||||
return;
|
||||
give_help(226,27);
|
||||
return;
|
||||
}
|
||||
|
||||
if(p.in(shop_done_rect)) {
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(done_btn->handleClick(loc))
|
||||
if(done_btn->handleClick(p))
|
||||
end_shop_mode();
|
||||
return;
|
||||
}
|
||||
@@ -675,8 +672,7 @@ void handle_talk_event(location p) {
|
||||
eTalkNode ttype;
|
||||
|
||||
if(p.in(talk_help_rect)) {
|
||||
location loc = {p.x + ul.x, p.y + ul.y};
|
||||
if(!help_btn->handleClick(loc))
|
||||
if(!help_btn->handleClick(p))
|
||||
return;
|
||||
give_help(205,6);
|
||||
return;
|
||||
|
||||
@@ -11,13 +11,6 @@
|
||||
#define ASB add_string_to_buf
|
||||
#define PSD univ.party.stuff_done
|
||||
|
||||
const int PC_WIN_UL_X = 291;
|
||||
const int PC_WIN_UL_Y = 5;
|
||||
const int ITEM_WIN_UL_X = 291;
|
||||
const int ITEM_WIN_UL_Y = 130;
|
||||
const int TEXT_WIN_UL_X = 291;
|
||||
const int TEXT_WIN_UL_Y = 283;
|
||||
|
||||
const int NUM_MONST_G = 173;
|
||||
const int NUM_TER_G = 251;
|
||||
const int NUM_ITEM_G = 120;
|
||||
|
||||
@@ -42,7 +42,6 @@ extern bool flushingInput;
|
||||
extern bool cartoon_happening, fog_lifted;
|
||||
extern short anim_step;
|
||||
extern effect_pat_type current_pat;
|
||||
extern location ul;
|
||||
extern location center;
|
||||
extern short which_combat_type;
|
||||
extern bool monsters_going,boom_anim_active;
|
||||
@@ -68,13 +67,14 @@ extern std::string save_talk_str1, save_talk_str2;
|
||||
|
||||
rectangle menuBarRect;
|
||||
Region originalGrayRgn, newGrayRgn, underBarRgn;
|
||||
sf::View mainView;
|
||||
|
||||
long anim_ticks = 0;
|
||||
|
||||
// 0 - terrain 1 - buttons 2 - pc stats
|
||||
// 3 - item stats 4 - text bar 5 - text area (not right)
|
||||
rectangle win_from_rects[6] = {{0,0,350,278},{0,0,37,258},{0,0,115,288},{0,0,143,288},{0,0,21,279},{0,0,0,288}};
|
||||
rectangle win_to_rects[6] = {{5,5,356,284},{383,5,421,271},{0,0,116,271},{0,0,144,271},{358,5,379,284},{0,0,138,256}};
|
||||
rectangle win_to_rects[6] = {{7,19,358,298},{385,19,423,285},{7,305,123,576},{132,305,276,576},{360,19,381,298},{285,305,423,561}};
|
||||
|
||||
// 0 - title 1 - button 2 - credits 3 - base button
|
||||
rectangle startup_from[4] = {{0,0,274,602},{274,0,322,301},{0,301,67,579},{274,301,314,341}};
|
||||
@@ -125,47 +125,61 @@ location ok_space[4] = {loc(),loc(),loc(),loc()};
|
||||
sf::Image hold_pict;
|
||||
|
||||
void adjust_window_mode() {
|
||||
sf::FloatRect r;
|
||||
sf::ContextSettings winSettings;
|
||||
winSettings.stencilBits = 1;
|
||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||
hideMenuBar();
|
||||
int menubarHeight = getMenubarHeight();
|
||||
bool firstTime = !mainPtr.isOpen();
|
||||
float width = 605, height = 430;
|
||||
location ul;
|
||||
|
||||
// TODO: Make display_mode an enum
|
||||
// 0 - center 1- ul 2 - ur 3 - dl 4 - dr 5 - small win
|
||||
if(get_int_pref("DisplayMode") == 5) {
|
||||
ul.x = 14; ul.y = 2;
|
||||
int height = 430 + menubarHeight;
|
||||
mainPtr.create(sf::VideoMode(605, height, 32), "Blades of Exile", sf::Style::Titlebar | sf::Style::Close, winSettings);
|
||||
mainPtr.setPosition({static_cast<int>((desktop.width - 605) / 2), static_cast<int>((desktop.height - height) / 2)});
|
||||
r = rectangle(mainPtr);
|
||||
}
|
||||
else {
|
||||
int mode = get_int_pref("DisplayMode");
|
||||
if(mode == 5) {
|
||||
int winHeight = height + menubarHeight;
|
||||
mainPtr.create(sf::VideoMode(width, winHeight, 32), "Blades of Exile", sf::Style::Titlebar | sf::Style::Close, winSettings);
|
||||
mainPtr.setPosition({static_cast<int>((desktop.width - width) / 2), static_cast<int>((desktop.height - height) / 2)});
|
||||
} else {
|
||||
mainPtr.create(desktop, "Blades of Exile", sf::Style::None, winSettings);
|
||||
mainPtr.setPosition({0,0});
|
||||
rectangle windRect(mainPtr);
|
||||
switch(get_int_pref("DisplayMode")) {
|
||||
case 0: ul.x = (windRect.right - 560) / 2; ul.y = (windRect.bottom - 422) / 2 + 14; break;
|
||||
case 1: ul.x = 10; ul.y = 28; break;
|
||||
case 2: ul.x = windRect.right - 570 - 6; ul.y = 28; break; // was 560. not 570
|
||||
case 3: ul.x = 10; ul.y = windRect.bottom - 422 - 6; break;
|
||||
case 4: ul.x = windRect.right - 570 - 6; ul.y = windRect.bottom - 422 - 6; break;
|
||||
}
|
||||
r = windRect;
|
||||
}
|
||||
|
||||
rectangle windRect(mainPtr);
|
||||
if(mode == 0) {
|
||||
ul.x = (windRect.right - width) / 2;
|
||||
ul.y = (windRect.bottom - height) / 2;
|
||||
} else if(mode < 5) {
|
||||
if(mode == 1 || mode == 3)
|
||||
ul.x = 10;
|
||||
else ul.x = windRect.right - width - 10;
|
||||
if(mode == 1 || mode == 2)
|
||||
ul.y = 28 + menubarHeight;
|
||||
else ul.y = windRect.bottom - height - 28;
|
||||
}
|
||||
|
||||
// Initialize the viewport for the game UI
|
||||
mainView.setSize(width, height);
|
||||
mainView.setCenter(/*ul.x +*/ width / 2, /*ul.y +*/ height / 2);
|
||||
sf::FloatRect mainPort;
|
||||
mainPort.left = float(ul.x) / windRect.width();
|
||||
mainPort.top = float(ul.y) / windRect.height();
|
||||
mainPort.width = width / windRect.width();
|
||||
mainPort.height = height / windRect.height();
|
||||
mainView.setViewport(mainPort);
|
||||
|
||||
#ifndef __APPLE__ // This overrides Dock icon on OSX, which isn't what we want at all
|
||||
ImageRsrc& icon = *ResMgr::get<ImageRsrc>("icon");
|
||||
mainPtr.setIcon(icon.getSize().x, icon.getSize().y, icon.copyToImage().getPixelsPtr());
|
||||
#endif
|
||||
if(!firstTime) redraw_screen(REFRESH_NONE);
|
||||
if(text_sbar) {
|
||||
text_sbar->relocate({ul.x + 546,ul.y + 283});
|
||||
item_sbar->relocate({ul.x + 546,ul.y + 146});
|
||||
shop_sbar->relocate({ul.x + 258,ul.y + 67});
|
||||
done_btn->relocate({ul.x + 217,ul.y + 393});
|
||||
help_btn->relocate({ul.x + 259,ul.y + 10});
|
||||
text_sbar->relocate({560,285});
|
||||
item_sbar->relocate({560,148});
|
||||
shop_sbar->relocate({272,69});
|
||||
done_btn->relocate({231,395});
|
||||
help_btn->relocate({273,12});
|
||||
}
|
||||
init_menubar();
|
||||
showMenuBar();
|
||||
@@ -179,19 +193,11 @@ void init_startup() {
|
||||
}
|
||||
|
||||
void draw_startup(short but_type) {
|
||||
rectangle to_rect;
|
||||
rectangle r1 = {-1000,-1000,5,1000},r2 = {-1000,-1000,1000,5},r3 = {418,-1000,2000,1000},
|
||||
r4 = {-1000,579,1000,2500};
|
||||
|
||||
sf::Texture& startup_gworld = *ResMgr::get<ImageRsrc>("startup");
|
||||
to_rect = startup_from[0];
|
||||
to_rect.offset(-13,5);
|
||||
rect_draw_some_item(startup_gworld,startup_from[0],to_rect,ul);
|
||||
to_rect = startup_top;
|
||||
to_rect.offset(ul);
|
||||
rect_draw_some_item(startup_gworld,startup_from[0],mainPtr,startup_top);
|
||||
|
||||
for(short i = 0; i < 5; i++) {
|
||||
rect_draw_some_item(startup_gworld,startup_from[1],startup_button[i],ul);
|
||||
rect_draw_some_item(startup_gworld,startup_from[1],mainPtr,startup_button[i]);
|
||||
draw_start_button(i,but_type);
|
||||
}
|
||||
draw_startup_anim(false);
|
||||
@@ -207,9 +213,9 @@ void draw_startup_anim(bool advance) {
|
||||
anim_from = anim_to;
|
||||
anim_from.offset(-1,-4 + startup_anim_pos);
|
||||
if(advance) startup_anim_pos = (startup_anim_pos + 1) % 542;
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startbut"),anim_size,startup_button[5],ul);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startbut"),anim_size,mainPtr,startup_button[5]);
|
||||
anim_to.offset(startup_button[5].left, startup_button[5].top);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startanim"),anim_from,anim_to,ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startanim"),anim_from,mainPtr,anim_to,sf::BlendAlpha);
|
||||
}
|
||||
|
||||
void draw_startup_stats() {
|
||||
@@ -226,22 +232,24 @@ void draw_startup_stats() {
|
||||
|
||||
if(!party_in_memory) {
|
||||
style.pointSize = 20;
|
||||
to_rect.offset(175,40);
|
||||
win_draw_string(mainPtr,to_rect,"No Party in Memory",eTextMode::WRAP,style,ul);
|
||||
to_rect.offset(193,40);
|
||||
win_draw_string(mainPtr,to_rect,"No Party in Memory",eTextMode::WRAP,style);
|
||||
} else {
|
||||
frame_rect = startup_top;
|
||||
frame_rect.inset(50,50);
|
||||
frame_rect.top += 30;
|
||||
frame_rect.offset(ul.x - 9,ul.y + 10);
|
||||
frame_rect.left += 18;
|
||||
frame_rect.offset(-9,10);
|
||||
// TODO: Maybe I should rename that variable
|
||||
::frame_rect(mainPtr, frame_rect, sf::Color::White);
|
||||
|
||||
to_rect.offset(203,37);
|
||||
win_draw_string(mainPtr,to_rect,"Your party:",eTextMode::WRAP,style,ul);
|
||||
to_rect.offset(221,37);
|
||||
win_draw_string(mainPtr,to_rect,"Your party:",eTextMode::WRAP,style);
|
||||
style.pointSize = 12;
|
||||
style.font = FONT_BOLD;
|
||||
for(short i = 0; i < 6; i++) {
|
||||
pc_rect = startup_top;
|
||||
pc_rect.left += 18;
|
||||
pc_rect.right = pc_rect.left + 300;
|
||||
pc_rect.bottom = pc_rect.top + 79;
|
||||
pc_rect.offset(60 + 232 * (i / 3) - 9,95 + 45 * (i % 3));
|
||||
@@ -253,7 +261,7 @@ void draw_startup_stats() {
|
||||
if(pic >= 1000) {
|
||||
sf::Texture* gw;
|
||||
graf_pos_ref(gw, from_rect) = spec_scen_g.find_graphic(pic % 1000, pic >= 10000);
|
||||
rect_draw_some_item(*gw,from_rect,to_rect,ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(*gw,from_rect,mainPtr,to_rect,sf::BlendAlpha);
|
||||
} else if(pic >= 100) {
|
||||
pic -= 100;
|
||||
// Note that we assume it's a 1x1 graphic.
|
||||
@@ -261,16 +269,16 @@ void draw_startup_stats() {
|
||||
from_rect = get_monster_template_rect(pic, 0, 0);
|
||||
int which_sheet = m_pic_index[pic].i / 20;
|
||||
sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet));
|
||||
rect_draw_some_item(monst_gworld,from_rect,to_rect,ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(monst_gworld,from_rect,mainPtr,to_rect,sf::BlendAlpha);
|
||||
} else {
|
||||
from_rect = calc_rect(2 * (pic / 8), pic % 8);
|
||||
sf::Texture& pc_gworld = *ResMgr::get<ImageRsrc>("pcs");
|
||||
rect_draw_some_item(pc_gworld,from_rect,to_rect,ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(pc_gworld,from_rect,mainPtr,to_rect,sf::BlendAlpha);
|
||||
}
|
||||
|
||||
style.pointSize = 14;
|
||||
pc_rect.offset(35,0);
|
||||
win_draw_string(mainPtr,pc_rect,univ.party[i].name,eTextMode::WRAP,style,ul);
|
||||
win_draw_string(mainPtr,pc_rect,univ.party[i].name,eTextMode::WRAP,style);
|
||||
to_rect.offset(pc_rect.left + 8,pc_rect.top + 8);
|
||||
|
||||
}
|
||||
@@ -302,7 +310,7 @@ void draw_startup_stats() {
|
||||
case eRace::BIRD: status += " Bird"; break;
|
||||
default: status += " *ERROR INVALID RACE*"; break;
|
||||
}
|
||||
win_draw_string(mainPtr,pc_rect,status,eTextMode::WRAP,style,ul);
|
||||
win_draw_string(mainPtr,pc_rect,status,eTextMode::WRAP,style);
|
||||
pc_rect.offset(0,13);
|
||||
status = "Health " + std::to_string(univ.party[i].max_health);
|
||||
status += ", Spell pts. " + std::to_string(univ.party[i].max_sp);
|
||||
@@ -324,7 +332,7 @@ void draw_startup_stats() {
|
||||
break;
|
||||
}
|
||||
if(!status.empty())
|
||||
win_draw_string(mainPtr,pc_rect,status,eTextMode::WRAP,style,ul);
|
||||
win_draw_string(mainPtr,pc_rect,status,eTextMode::WRAP,style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,13 +346,13 @@ void draw_startup_stats() {
|
||||
std::string copyright = sout.str();
|
||||
style.font = FONT_BOLD;
|
||||
style.pointSize = 10;
|
||||
pc_rect = startup_from[0];
|
||||
pc_rect = startup_top;
|
||||
pc_rect.offset(5,5);
|
||||
pc_rect.top = pc_rect.bottom - 25;
|
||||
pc_rect.left = pc_rect.right - string_length(copyright, style) - 45;
|
||||
pc_rect.top = pc_rect.bottom - 30;
|
||||
pc_rect.left = pc_rect.right - string_length(copyright, style) - 32;
|
||||
// TODO: Should replace this with a more appropriate copyright string
|
||||
// Windows replaced it with "That is not dead which can eternally lie..." - I don't think that's quite appropriate though.
|
||||
win_draw_string(mainPtr, pc_rect, copyright, eTextMode::WRAP, style, ul);
|
||||
win_draw_string(mainPtr, pc_rect, copyright, eTextMode::WRAP, style);
|
||||
}
|
||||
|
||||
|
||||
@@ -363,7 +371,7 @@ void draw_start_button(short which_position,short which_button) {
|
||||
to_rect.left += 4; to_rect.top += 4;
|
||||
to_rect.right = to_rect.left + 40;
|
||||
to_rect.bottom = to_rect.top + 40;
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startup"),from_rect,to_rect,ul);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("startup"),from_rect,mainPtr,to_rect);
|
||||
|
||||
TextStyle style;
|
||||
style.font = FONT_DUNGEON;
|
||||
@@ -377,7 +385,7 @@ void draw_start_button(short which_position,short which_button) {
|
||||
base_color.b += (48 * which_button);
|
||||
style.colour = base_color;
|
||||
style.lineHeight = 18;
|
||||
win_draw_string(mainPtr,to_rect,button_labels[which_position],eTextMode::CENTRE,style,ul);
|
||||
win_draw_string(mainPtr,to_rect,button_labels[which_position],eTextMode::CENTRE,style);
|
||||
}
|
||||
|
||||
void main_button_click(int which_button) {
|
||||
@@ -392,7 +400,6 @@ void main_button_click(int which_button) {
|
||||
}
|
||||
|
||||
void arrow_button_click(rectangle button_rect) {
|
||||
button_rect.offset(ul);
|
||||
mainPtr.setActive();
|
||||
clip_rect(mainPtr, button_rect);
|
||||
// TODO: Mini-event loop so that the click doesn't happen until releasing the mouse button
|
||||
@@ -450,7 +457,9 @@ void redraw_screen(int refresh) {
|
||||
if(refresh & REFRESH_INVEN) put_item_screen(stat_window);
|
||||
if(refresh & REFRESH_TRANS) print_buf();
|
||||
|
||||
mainPtr.setView(mainPtr.getDefaultView());
|
||||
put_background();
|
||||
mainPtr.setView(mainView);
|
||||
switch(overall_mode) {
|
||||
case MODE_STARTUP:
|
||||
draw_startup(0);
|
||||
@@ -581,8 +590,7 @@ void draw_buttons(short mode) {
|
||||
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);
|
||||
to_rect.offset(win_to_rects[WINRECT_ACTBTNS].topLeft());
|
||||
if(i == mode)
|
||||
fill_rect(mainPtr, to_rect, sf::Color::Blue);
|
||||
else fill_rect(mainPtr, to_rect, sf::Color::Black);
|
||||
@@ -594,8 +602,7 @@ void draw_buttons(short mode) {
|
||||
}
|
||||
button_gw.display();
|
||||
|
||||
dest_rec = win_to_rects[1];
|
||||
dest_rec.offset(ul);
|
||||
dest_rec = win_to_rects[WINRECT_ACTBTNS];
|
||||
rect_draw_some_item(button_gw.getTexture(), rectangle(button_gw), mainPtr, dest_rec, sf::BlendAdd);
|
||||
}
|
||||
|
||||
@@ -642,7 +649,7 @@ void draw_text_bar() {
|
||||
|
||||
void put_text_bar(std::string str) {
|
||||
text_bar_gworld.setActive();
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("textbar"), win_from_rects[4], text_bar_gworld, win_from_rects[4]);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("textbar"), win_from_rects[WINRECT_STATUS], text_bar_gworld, win_from_rects[WINRECT_STATUS]);
|
||||
TextStyle style;
|
||||
style.colour = sf::Color::White;
|
||||
style.font = FONT_BOLD;
|
||||
@@ -682,7 +689,7 @@ void put_text_bar(std::string str) {
|
||||
|
||||
void refresh_text_bar() {
|
||||
mainPtr.setActive();
|
||||
rect_draw_some_item(text_bar_gworld.getTexture(), win_from_rects[4], win_to_rects[4],ul);
|
||||
rect_draw_some_item(text_bar_gworld.getTexture(), win_from_rects[WINRECT_STATUS], mainPtr, win_to_rects[WINRECT_STATUS]);
|
||||
}
|
||||
|
||||
// this is used for determinign whether to round off walkway corners
|
||||
@@ -1409,10 +1416,10 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
|
||||
dest_rect.offset(x_adj,y_adj);
|
||||
dest_rect &= big_to;
|
||||
|
||||
dest_rect.offset(win_to_rects[0].left,win_to_rects[0].top);
|
||||
dest_rect.offset(win_to_rects[WINRECT_TERVIEW].topLeft());
|
||||
|
||||
source_rect.offset(-store_rect.left + 28 * type,-store_rect.top);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("booms"),source_rect,dest_rect,ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(*ResMgr::get<ImageRsrc>("booms"),source_rect,mainPtr,dest_rect,sf::BlendAlpha);
|
||||
|
||||
if(damage > 0 && dest_rect.right - dest_rect.left >= 28 && dest_rect.bottom - dest_rect.top >= 36) {
|
||||
TextStyle style;
|
||||
@@ -1424,12 +1431,12 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
|
||||
std::string dam_str = std::to_string(damage);
|
||||
style.colour = sf::Color::White;
|
||||
text_rect.offset(-1,-1);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style,ul);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style);
|
||||
text_rect.offset(2,2);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style,ul);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style);
|
||||
style.colour = sf::Color::Black;
|
||||
text_rect.offset(-1,-1);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style,ul);
|
||||
win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style);
|
||||
}
|
||||
mainPtr.display();
|
||||
bool skip_boom_delay = get_bool_pref("SkipBoomDelay");
|
||||
@@ -1448,32 +1455,47 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
|
||||
frame_active_pc(center);
|
||||
}
|
||||
|
||||
// dir = 0 - down, 1 - left, 2 - right, 3 - up
|
||||
// pos = row or column to centre the arrow in, range 0..8
|
||||
static void draw_one_pointing_arrow(int dir, int pos) {
|
||||
rectangle from_rect = {351, 1, 359, 9};
|
||||
from_rect.offset(9 * dir, 0);
|
||||
|
||||
rectangle ter_view_rect = win_to_rects[WINRECT_TERVIEW];
|
||||
rectangle to_rect;
|
||||
|
||||
if(dir == 0 || dir == 3)
|
||||
to_rect.left = ter_view_rect.left + 23 + pos * 28;
|
||||
else to_rect.top = ter_view_rect.top + 23 + pos * 36;
|
||||
if(dir == 0) to_rect.top = ter_view_rect.bottom - 10;
|
||||
else if(dir == 1) to_rect.left = ter_view_rect.left + 2;
|
||||
else if(dir == 2) to_rect.left = ter_view_rect.right - 10;
|
||||
else if(dir == 3) to_rect.top = ter_view_rect.top + 2;
|
||||
|
||||
to_rect.width() = to_rect.height() = 8;
|
||||
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(), from_rect, mainPtr, to_rect, sf::BlendAlpha);
|
||||
}
|
||||
|
||||
void draw_pointing_arrows() {
|
||||
static const rectangle sources[4] = {
|
||||
{351,28,359,36}, // up
|
||||
{351,10,359,18}, // left
|
||||
{351,01,359,9}, // down
|
||||
{351,19,359,27} // right
|
||||
};
|
||||
static const rectangle dests[8] = {
|
||||
{7,100,15,108},{7,170,15,178},{140,7,148,15},{212,7,220,15},
|
||||
{346,100,354,108},{346,170,354,178},{140,274,148,282},{212,274,220,282}
|
||||
};
|
||||
|
||||
if(monsters_going || !scrollableModes.count(overall_mode))
|
||||
return;
|
||||
for(short i = 0; i < 4; i++) {
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),sources[i],dests[i * 2],ul,sf::BlendAlpha);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),sources[i],dests[i * 2 + 1],ul,sf::BlendAlpha);
|
||||
}
|
||||
|
||||
draw_one_pointing_arrow(0, 3);
|
||||
draw_one_pointing_arrow(0, 5);
|
||||
draw_one_pointing_arrow(1, 3);
|
||||
draw_one_pointing_arrow(1, 5);
|
||||
draw_one_pointing_arrow(2, 3);
|
||||
draw_one_pointing_arrow(2, 5);
|
||||
draw_one_pointing_arrow(3, 3);
|
||||
draw_one_pointing_arrow(3, 5);
|
||||
}
|
||||
|
||||
void redraw_terrain() {
|
||||
rectangle to_rect;
|
||||
|
||||
to_rect = win_to_rects[0];
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(), win_from_rects[0], to_rect,ul);
|
||||
to_rect = win_to_rects[WINRECT_TERVIEW];
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(), win_from_rects[WINRECT_TERVIEW], mainPtr, to_rect);
|
||||
apply_light_mask(true);
|
||||
|
||||
|
||||
@@ -1485,16 +1507,15 @@ void redraw_terrain() {
|
||||
|
||||
|
||||
void draw_targets(location center) {
|
||||
rectangle source_rect = {74,36,85,47},dest_rect;
|
||||
|
||||
if(!univ.party.is_alive())
|
||||
return;
|
||||
|
||||
sf::Texture& src_gworld = *ResMgr::get<ImageRsrc>("trim");
|
||||
for(short i = 0; i < 8; i++)
|
||||
if((spell_targets[i].x != 120) && (point_onscreen(center,spell_targets[i]))) {
|
||||
dest_rect = coord_to_rect(spell_targets[i].x - center.x + 4,spell_targets[i].y - center.y + 4);
|
||||
rect_draw_some_item(src_gworld,calc_rect(6,0),dest_rect,ul,sf::BlendAlpha);
|
||||
rectangle dest_rect = coord_to_rect(spell_targets[i].x - center.x + 4,spell_targets[i].y - center.y + 4);
|
||||
dest_rect.offset(win_to_rects[WINRECT_TERVIEW].topLeft());
|
||||
rect_draw_some_item(src_gworld,calc_rect(6,0),mainPtr,dest_rect,sf::BlendAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1509,11 +1530,11 @@ void frame_space(location where,short mode,short width,short height) {
|
||||
where_put.x = 4 + where.x - center.x;
|
||||
where_put.y = 4 + where.y - center.y;
|
||||
|
||||
to_frame.top = 18 + where_put.y * 36;
|
||||
to_frame.left = 18 + where_put.x * 28;
|
||||
to_frame.bottom = 54 + where_put.y * 36 + 36 * (height - 1);
|
||||
to_frame.right = 46 + where_put.x * 28 + 28 * (width - 1);
|
||||
to_frame.offset(ul);
|
||||
to_frame.top = 13 + where_put.y * 36;
|
||||
to_frame.left = 13 + where_put.x * 28;
|
||||
to_frame.bottom = 49 + where_put.y * 36 + 36 * (height - 1);
|
||||
to_frame.right = 41 + where_put.x * 28 + 28 * (width - 1);
|
||||
to_frame.offset(win_to_rects[WINRECT_TERVIEW].topLeft());
|
||||
|
||||
frame_roundrect(mainPtr, to_frame, 8, (mode == 0) ? sf::Color::Red : sf::Color::Green);
|
||||
}
|
||||
@@ -1529,9 +1550,12 @@ void erase_spot(short i,short j) {
|
||||
|
||||
void draw_targeting_line(location where_curs) {
|
||||
location which_space,store_loc;
|
||||
rectangle redraw_rect,redraw_rect2,terrain_rect = {0,0,351,279},target_rect;
|
||||
rectangle redraw_rect,redraw_rect2,target_rect;
|
||||
location from_loc;
|
||||
rectangle on_screen_terrain_area = {23, 23, 346, 274};
|
||||
rectangle on_screen_terrain_area = win_to_rects[WINRECT_TERVIEW];
|
||||
on_screen_terrain_area.inset(13, 13);
|
||||
|
||||
where_curs = mainPtr.mapPixelToCoords(where_curs, mainView);
|
||||
|
||||
if(overall_mode >= MODE_COMBAT)
|
||||
from_loc = univ.current_pc().combat_pos;
|
||||
@@ -1539,29 +1563,26 @@ void draw_targeting_line(location where_curs) {
|
||||
if((overall_mode == MODE_SPELL_TARGET) || (overall_mode == MODE_FIRING) || (overall_mode == MODE_THROWING) || (overall_mode == MODE_FANCY_TARGET)
|
||||
|| ((overall_mode == MODE_TOWN_TARGET) && (current_pat.pattern[4][4] != 0))) {
|
||||
|
||||
on_screen_terrain_area.offset(ul);
|
||||
if(where_curs.in(on_screen_terrain_area)) {
|
||||
// && (point_onscreen(center,univ.party[current_pc].combat_pos))){
|
||||
which_space.x = center.x + (where_curs.x - 23 - ul.x) / 28 - 4;
|
||||
which_space.y = center.y + (where_curs.y - 23 - ul.y) / 36 - 4;
|
||||
which_space.x = center.x + (where_curs.x - 37) / 28 - 4;
|
||||
which_space.y = center.y + (where_curs.y - 25) / 36 - 4;
|
||||
|
||||
int xBound = (short) (from_loc.x - center.x + 4);
|
||||
int yBound = (short) (from_loc.y - center.y + 4);
|
||||
xBound = (xBound * 28) + 32 + ul.x;
|
||||
yBound = (yBound * 36) + 36 + ul.y;
|
||||
xBound = (xBound * 28) + 46;
|
||||
yBound = (yBound * 36) + 38;
|
||||
|
||||
if((can_see_light(from_loc,which_space,sight_obscurity) < 5)
|
||||
&& (dist(from_loc,which_space) <= current_spell_range)) {
|
||||
terrain_rect.inset(13,13);
|
||||
terrain_rect.offset(5 + ul.x,5 + ul.y);
|
||||
mainPtr.setActive();
|
||||
clip_rect(mainPtr, terrain_rect);
|
||||
clip_rect(mainPtr, on_screen_terrain_area);
|
||||
draw_line(mainPtr, where_curs, location(xBound, yBound), 2, {128,128,128}, sf::BlendAdd);
|
||||
redraw_rect.left = min(where_curs.x,xBound) - 4;
|
||||
redraw_rect.right = max(where_curs.x,xBound) + 4;
|
||||
redraw_rect.top = min(where_curs.y,yBound) - 4;
|
||||
redraw_rect.bottom = max(where_curs.y,yBound) + 4;
|
||||
redraw_rect2 = redraw_rect & terrain_rect;
|
||||
redraw_rect2 = redraw_rect & on_screen_terrain_area;
|
||||
|
||||
// Now place targeting pattern
|
||||
for(short i = 0; i < 9; i++)
|
||||
@@ -1571,9 +1592,9 @@ void draw_targeting_line(location where_curs) {
|
||||
if((abs(store_loc.x - which_space.x) <= 4) &&
|
||||
(abs(store_loc.y - which_space.y) <= 4) &&
|
||||
(current_pat.pattern[store_loc.x - which_space.x + 4][store_loc.y - which_space.y + 4] != 0)) {
|
||||
target_rect.left = 13 + 28 * i + 5 + ul.x;
|
||||
target_rect.left = 13 + 28 * i + 19;
|
||||
target_rect.right = target_rect.left + 28;
|
||||
target_rect.top = 13 + 36 * j + 5 + ul.y;
|
||||
target_rect.top = 13 + 36 * j + 7;
|
||||
target_rect.bottom = target_rect.top + 36;
|
||||
frame_rect(mainPtr, target_rect, sf::Color::White);
|
||||
target_rect.inset(-5,-5);
|
||||
@@ -1605,12 +1626,11 @@ void redraw_partial_terrain(rectangle redraw_rect) {
|
||||
rectangle from_rect;
|
||||
|
||||
from_rect = redraw_rect;
|
||||
from_rect.offset(-ul.x,-ul.y);
|
||||
|
||||
// as rect_draw_some_item will shift redraw_rect before drawing, we need to compensate
|
||||
redraw_rect.offset(-ul.x + 5,-ul.y + 5);
|
||||
redraw_rect.offset(5,5);
|
||||
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),from_rect,redraw_rect,ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),from_rect,mainPtr,redraw_rect);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ extern short combat_posing_monster , current_working_monster ; // 0-5 PC 100 + x
|
||||
extern sf::RenderTexture terrain_screen_gworld;
|
||||
extern std::queue<pending_special_type> special_queue;
|
||||
|
||||
extern location ul;
|
||||
extern location center;
|
||||
extern short which_combat_type;
|
||||
extern bool monsters_going,anim_onscreen;
|
||||
@@ -273,7 +272,7 @@ void frame_active_pc(location center) {
|
||||
active_pc_rect.left = 18 + where_draw.x * 28;
|
||||
active_pc_rect.bottom = 54 + where_draw.y * 36;
|
||||
active_pc_rect.right = 46 + where_draw.x * 28;
|
||||
active_pc_rect.offset(ul);
|
||||
active_pc_rect.offset(14,2);
|
||||
|
||||
frame_roundrect(mainPtr, active_pc_rect, 8, sf::Color::Magenta);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ short on_spell_menu[2][62];
|
||||
short on_monst_menu[256];
|
||||
|
||||
extern bool map_visible;
|
||||
extern sf::View mainView;
|
||||
|
||||
std::string scenario_temp_dir_name = "scenario";
|
||||
|
||||
@@ -71,7 +72,6 @@ bool finished_init = false;
|
||||
|
||||
sf::RenderWindow mini_map;
|
||||
short which_item_page[6] = {0,0,0,0,0,0}; // Remembers which of the 2 item pages pc looked at
|
||||
location ul = {28,10};
|
||||
short current_ground = 0;
|
||||
eStatMode stat_screen_mode;
|
||||
short anim_step = -1;
|
||||
@@ -320,6 +320,7 @@ void Mouse_Pressed() {
|
||||
|
||||
if(overall_mode != MODE_STARTUP) {
|
||||
location mousePos(event.mouseButton.x, event.mouseButton.y);
|
||||
mousePos = mainPtr.mapPixelToCoords(mousePos, mainView);
|
||||
volatile bool doneScrolling = false;
|
||||
if(mousePos.in(text_sbar->getBounds())) {
|
||||
mainPtr.setActive(false);
|
||||
@@ -625,10 +626,11 @@ static cursor_type get_mode_cursor(){
|
||||
void change_cursor(location where_curs) {
|
||||
cursor_type cursor_needed;
|
||||
location cursor_direction;
|
||||
rectangle world_screen = {23, 23, 346, 274};
|
||||
extern rectangle win_to_rects[6];
|
||||
rectangle world_screen = win_to_rects[WINRECT_TERVIEW];
|
||||
world_screen.inset(13, 13);
|
||||
|
||||
where_curs.x -= ul.x;
|
||||
where_curs.y -= ul.y;
|
||||
where_curs = mainPtr.mapPixelToCoords(where_curs, mainView);
|
||||
|
||||
if(!world_screen.contains(where_curs))
|
||||
cursor_needed = sword_curs;
|
||||
|
||||
@@ -48,7 +48,6 @@ short monsters_faces[190] = {
|
||||
0,0,0,0,26,26,0,0,0,50,
|
||||
23,0,0,0,0,0,0,0,23,23,
|
||||
0,0,0,55,23,36,31,0,0,0};
|
||||
extern location ul;
|
||||
extern rectangle windRect;
|
||||
extern long anim_ticks;
|
||||
extern tessel_ref_t bg[];
|
||||
@@ -73,6 +72,7 @@ extern bool fog_lifted;
|
||||
extern const short alch_difficulty[20];
|
||||
extern const eItemAbil alch_ingred1[20];
|
||||
extern const eItemAbil alch_ingred2[20];
|
||||
extern rectangle win_to_rects[6];
|
||||
|
||||
// Talk vars
|
||||
extern eGameMode store_pre_talk_mode;
|
||||
@@ -228,7 +228,6 @@ void apply_light_mask(bool onWindow) {
|
||||
}
|
||||
|
||||
dark_mask_region.offset(5,5);
|
||||
dark_mask_region.offset(ul);
|
||||
}
|
||||
|
||||
void start_missile_anim() {
|
||||
@@ -273,8 +272,6 @@ void add_missile(location dest,miss_num_t missile_type,short path_type,short x_a
|
||||
}
|
||||
|
||||
void run_a_missile(location from,location fire_to,miss_num_t miss_type,short path,short sound_num,short x_adj,short y_adj,short len) {
|
||||
// if((cartoon_happening) && (anim_step < 140))
|
||||
// return;
|
||||
start_missile_anim();
|
||||
add_missile(fire_to,miss_type,path, x_adj, y_adj);
|
||||
do_missile_anim(len,from, sound_num);
|
||||
@@ -282,9 +279,6 @@ void run_a_missile(location from,location fire_to,miss_num_t miss_type,short pat
|
||||
}
|
||||
|
||||
void run_a_boom(location boom_where,short type,short x_adj,short y_adj,short snd) {
|
||||
|
||||
// if((cartoon_happening) && (anim_step < 140))
|
||||
// return;
|
||||
if((type < 0) || (type > 2))
|
||||
return;
|
||||
start_missile_anim();
|
||||
@@ -338,7 +332,7 @@ void do_missile_anim(short num_steps,location missile_origin,short sound_num) {
|
||||
|
||||
short x1[30],x2[30],y1[30],y2[30]; // for path paramaterization
|
||||
rectangle missile_place_rect[30],missile_origin_rect[30];
|
||||
location current_terrain_ul;
|
||||
location current_terrain_ul = win_to_rects[WINRECT_TERVIEW].topLeft();
|
||||
|
||||
if(!have_missile || !boom_anim_active) {
|
||||
boom_anim_active = false;
|
||||
@@ -349,20 +343,13 @@ void do_missile_anim(short num_steps,location missile_origin,short sound_num) {
|
||||
return m.missile_type == 0;
|
||||
})) return;
|
||||
|
||||
// initialize general data
|
||||
// TODO: This is probably yet another relic of the Exile III demo
|
||||
if(overall_mode == MODE_STARTUP) {
|
||||
current_terrain_ul.x = 306;
|
||||
current_terrain_ul.y = 5;
|
||||
} else current_terrain_ul.x = current_terrain_ul.y = 5;
|
||||
|
||||
// make terrain_template contain current terrain all nicely
|
||||
draw_terrain(1);
|
||||
to_rect = rectangle(terrain_screen_gworld);
|
||||
to_rect.bottom -= 10; // Adjust for pointing buttons
|
||||
rectangle oldBounds = to_rect;
|
||||
to_rect.offset(current_terrain_ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldBounds,to_rect,ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldBounds,mainPtr,to_rect);
|
||||
|
||||
mainPtr.setActive();
|
||||
|
||||
@@ -411,7 +398,6 @@ void do_missile_anim(short num_steps,location missile_origin,short sound_num) {
|
||||
temp_rect = missile_origin_base;
|
||||
temp_rect.offset(-8 + x2[i] + (x1[i] * t) / num_steps,
|
||||
-8 + y2[i] + (y1[i] * t) / num_steps);
|
||||
temp_rect.offset(ul);
|
||||
temp_rect.offset(current_terrain_ul);
|
||||
|
||||
// now adjust for different paths
|
||||
@@ -461,7 +447,7 @@ void do_missile_anim(short num_steps,location missile_origin,short sound_num) {
|
||||
to_rect.bottom -= 10; // Adjust for pointing buttons
|
||||
rectangle oldRect = to_rect;
|
||||
to_rect.offset(current_terrain_ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldRect,to_rect,ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldRect,mainPtr,to_rect);
|
||||
}
|
||||
|
||||
short get_missile_direction(location origin_point,location the_point) {
|
||||
@@ -506,7 +492,7 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
|
||||
location screen_ul;
|
||||
|
||||
short cur_boom_type = 0;
|
||||
location current_terrain_ul;
|
||||
location current_terrain_ul = win_to_rects[WINRECT_TERVIEW].topLeft();;
|
||||
short boom_type_sound[6] = {5,10,53,53,53,75};
|
||||
|
||||
if(!have_boom || !boom_anim_active) {
|
||||
@@ -518,13 +504,6 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
|
||||
return b.boom_type == 0;
|
||||
})) return;
|
||||
|
||||
// initialize general data
|
||||
if(overall_mode == MODE_STARTUP) {
|
||||
// TODO: I think this is a relic of the "demo" on the main screen of Exile III
|
||||
current_terrain_ul.x = 306;
|
||||
current_terrain_ul.y = 5;
|
||||
} else current_terrain_ul.x = current_terrain_ul.y = 5;
|
||||
|
||||
// make terrain_template contain current terrain all nicely
|
||||
draw_terrain(1);
|
||||
if(special_draw != 2) {
|
||||
@@ -532,7 +511,7 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
|
||||
to_rect.bottom -= 10; // Adjust for pointing buttons
|
||||
rectangle oldRect = to_rect;
|
||||
to_rect.offset(current_terrain_ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldRect,to_rect,ul);
|
||||
rect_draw_some_item(terrain_screen_gworld.getTexture(),oldRect,mainPtr,to_rect);
|
||||
}
|
||||
|
||||
TextStyle style;
|
||||
@@ -549,7 +528,6 @@ void do_explosion_anim(short /*sound_num*/,short special_draw, short snd) {
|
||||
explode_place_rect[i] = base_rect;
|
||||
explode_place_rect[i].offset(13 + 28 * (store_booms[i].dest.x - screen_ul.x) + store_booms[i].x_adj,
|
||||
13 + 36 * (store_booms[i].dest.y - screen_ul.y) + store_booms[i].y_adj);
|
||||
explode_place_rect[i].offset(ul);
|
||||
explode_place_rect[i].offset(current_terrain_ul);
|
||||
|
||||
if((store_booms[i].place_type == 1) && (special_draw < 2)) {
|
||||
@@ -826,15 +804,14 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) {
|
||||
void refresh_shopping() {
|
||||
rectangle from_rect(talk_gworld);
|
||||
rectangle to_rect = from_rect;
|
||||
to_rect.offset(5,5);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),from_rect,to_rect,ul);
|
||||
to_rect.offset(19,7);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),from_rect,mainPtr,to_rect);
|
||||
shop_sbar->draw();
|
||||
}
|
||||
|
||||
static void place_talk_face() {
|
||||
rectangle face_rect = {6,6,38,38};
|
||||
face_rect.offset(talk_area_rect.topLeft());
|
||||
face_rect.offset(ul);
|
||||
mainPtr.setActive();
|
||||
short face_to_draw = univ.scenario.scen_monsters[store_monst_type].default_facial_pic;
|
||||
if(store_talk_face_pic >= 0)
|
||||
@@ -853,9 +830,8 @@ static void place_talk_face() {
|
||||
void click_talk_rect(word_rect_t word) {
|
||||
rectangle talkRect(talk_gworld), wordRect(word.rect);
|
||||
mainPtr.setActive();
|
||||
rect_draw_some_item(talk_gworld.getTexture(),talkRect,talk_area_rect,ul);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),talkRect,mainPtr,talk_area_rect);
|
||||
wordRect.offset(talk_area_rect.topLeft());
|
||||
wordRect.offset(ul);
|
||||
TextStyle style;
|
||||
style.font = FONT_DUNGEON;
|
||||
style.pointSize = 18;
|
||||
@@ -865,7 +841,7 @@ void click_talk_rect(word_rect_t word) {
|
||||
place_talk_face();
|
||||
mainPtr.display();
|
||||
play_sound(37, time_in_ticks(5));
|
||||
rect_draw_some_item(talk_gworld.getTexture(),talkRect,talk_area_rect,ul);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),talkRect,mainPtr,talk_area_rect);
|
||||
place_talk_face();
|
||||
}
|
||||
|
||||
@@ -953,7 +929,6 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
|
||||
if(c_rect.right > 0) {
|
||||
mainPtr.setActive();
|
||||
c_rect.offset(talk_area_rect.topLeft());
|
||||
c_rect.offset(ul);
|
||||
clip_rect(mainPtr, c_rect);
|
||||
}
|
||||
|
||||
@@ -1055,14 +1030,14 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
|
||||
|
||||
// Finally place processed graphics
|
||||
mainPtr.setActive();
|
||||
rect_draw_some_item(talk_gworld.getTexture(),oldRect,talk_area_rect,ul);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),oldRect,mainPtr,talk_area_rect);
|
||||
// I have no idea what this check is for; I'm jsut preserving it in case it was important
|
||||
if(c_rect.right == 0) place_talk_face();
|
||||
}
|
||||
|
||||
void refresh_talking() {
|
||||
rectangle tempRect(talk_gworld);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),tempRect,talk_area_rect,ul);
|
||||
rect_draw_some_item(talk_gworld.getTexture(),tempRect,mainPtr,talk_area_rect);
|
||||
place_talk_face();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ using std::vector;
|
||||
extern bool party_in_memory;
|
||||
extern long register_flag;
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern location ul;
|
||||
extern std::vector<scen_header_type> scen_headers;
|
||||
extern cUniverse univ;
|
||||
extern eGameMode overall_mode;
|
||||
extern sf::View mainView;
|
||||
|
||||
rectangle startup_button[6];
|
||||
|
||||
@@ -42,8 +42,7 @@ bool handle_startup_press(location the_point) {
|
||||
std::string scen_name;
|
||||
bool force_party = false;
|
||||
|
||||
the_point.x -= ul.x;
|
||||
the_point.y -= ul.y;
|
||||
the_point = mainPtr.mapPixelToCoords(the_point, mainView);
|
||||
|
||||
for(short i = 0; i < 5; i++)
|
||||
if(the_point.in(startup_button[i])) {
|
||||
|
||||
@@ -64,7 +64,6 @@ extern sf::RenderTexture pc_stats_gworld, item_stats_gworld, text_area_gworld;
|
||||
extern sf::RenderTexture terrain_screen_gworld;
|
||||
|
||||
// game globals
|
||||
extern location ul;
|
||||
extern rectangle item_buttons[8][6];
|
||||
// name, use, give, drip, info, sell/id
|
||||
extern rectangle pc_buttons[6][5];
|
||||
@@ -599,23 +598,13 @@ short first_active_pc() {
|
||||
|
||||
void refresh_stat_areas(short mode) {
|
||||
sf::BlendMode x;
|
||||
rectangle dest_rect,parts_of_area_to_draw[3] = {{0,0,17,271},{16,0,123,256},{123,0,144,271}};
|
||||
extern rectangle win_to_rects[6];
|
||||
|
||||
dest_rect = rectangle(pc_stats_gworld);
|
||||
rectangle oldRect = dest_rect;
|
||||
dest_rect.offset(PC_WIN_UL_X,PC_WIN_UL_Y);
|
||||
if(mode == 1) x = sf::BlendAdd;
|
||||
else x = sf::BlendNone;
|
||||
rect_draw_some_item (pc_stats_gworld.getTexture(), oldRect, dest_rect,ul, x);
|
||||
for(short i = 0; i < 3; i++) {
|
||||
dest_rect = parts_of_area_to_draw[i];
|
||||
dest_rect.offset(ITEM_WIN_UL_X,ITEM_WIN_UL_Y);
|
||||
rect_draw_some_item(item_stats_gworld.getTexture(), parts_of_area_to_draw[i], dest_rect,ul, x);
|
||||
}
|
||||
dest_rect = rectangle(text_area_gworld);
|
||||
oldRect = dest_rect;
|
||||
dest_rect.offset(TEXT_WIN_UL_X,TEXT_WIN_UL_Y);
|
||||
rect_draw_some_item(text_area_gworld.getTexture(),oldRect, dest_rect,ul, x);
|
||||
rect_draw_some_item(pc_stats_gworld.getTexture(), rectangle(pc_stats_gworld), mainPtr, win_to_rects[WINRECT_PCSTATS], x);
|
||||
rect_draw_some_item(item_stats_gworld.getTexture(), rectangle(item_stats_gworld), mainPtr, win_to_rects[WINRECT_INVEN], x);
|
||||
rect_draw_some_item(text_area_gworld.getTexture(), rectangle(text_area_gworld), mainPtr, win_to_rects[WINRECT_TRANSCRIPT], x);
|
||||
}
|
||||
|
||||
// get job info gone
|
||||
@@ -1132,7 +1121,7 @@ void Draw_Some_Item (sf::Texture& src_gworld, rectangle src_rect, sf::RenderTarg
|
||||
return;
|
||||
|
||||
destrec = coord_to_rect(target.x,target.y);
|
||||
if(main_win == 1) destrec.offset(ul.x + 5,ul.y + 5);
|
||||
if(main_win == 1) destrec.offset(5,5);
|
||||
|
||||
if(main_win == 0) {
|
||||
if(masked == 1)
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
sf::Shader maskShader;
|
||||
extern fs::path progDir;
|
||||
// TODO: Shouldn't need this
|
||||
extern sf::RenderWindow mainPtr;
|
||||
|
||||
void init_shaders() {
|
||||
fs::path shaderPath = progDir/"data"/"shaders";
|
||||
@@ -90,11 +88,6 @@ void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,sf::Re
|
||||
targ_gworld.draw(tile, mode);
|
||||
}
|
||||
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,rectangle targ_rect,location offset, sf::BlendMode mode) {
|
||||
targ_rect.offset(offset);
|
||||
rect_draw_some_item(src_gworld,src_rect,mainPtr,targ_rect,mode);
|
||||
}
|
||||
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,const sf::Texture& mask_gworld,sf::RenderTarget& targ_gworld,rectangle targ_rect) {
|
||||
static sf::RenderTexture src;
|
||||
static bool inited = false;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
void init_shaders();
|
||||
void rect_draw_some_item(sf::RenderTarget& targ_gworld,rectangle targ_rect);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,sf::RenderTarget& targ_gworld,rectangle targ_rect,sf::BlendMode mode = sf::BlendNone);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,rectangle targ_rect,location offset,sf::BlendMode mode = sf::BlendNone);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,const sf::Texture& mask_gworld,sf::RenderTarget& targ_gworld,rectangle targ_rect);
|
||||
void draw_splash(const sf::Texture& splash, sf::RenderWindow& targ, rectangle dest_rect);
|
||||
|
||||
|
||||
@@ -215,8 +215,11 @@ void clip_rect(sf::RenderTarget& where, rectangle rect) {
|
||||
rect &= rectangle(where); // Make sure we don't draw out of bounds
|
||||
// TODO: Make sure this works for the scissor test...
|
||||
setActiveRenderTarget(where);
|
||||
rectangle winRect(where);
|
||||
location pivot = rect.bottomLeft();
|
||||
pivot = where.mapCoordsToPixel(pivot);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(rect.left, rectangle(where).height() - rect.bottom, rect.width(), rect.height());
|
||||
glScissor(pivot.x, rectangle(where).height() - pivot.y, rect.width(), rect.height());
|
||||
}
|
||||
|
||||
void clip_region(sf::RenderWindow& where, Region& region) {
|
||||
|
||||
@@ -38,7 +38,6 @@ struct text_params_t {
|
||||
TextStyle style;
|
||||
eTextMode mode;
|
||||
bool showBreaks = false;
|
||||
location offset = {0,0};
|
||||
// Hilite ranges are, like the STL, of the form [first, last).
|
||||
std::vector<hilite_t> hilite_ranges;
|
||||
sf::Color hilite_fg, hilite_bg = sf::Color::Transparent;
|
||||
@@ -95,8 +94,6 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st
|
||||
short total_width = 0;
|
||||
short adjust_x = 0,adjust_y = 0;
|
||||
|
||||
adjust_x = options.offset.x;
|
||||
adjust_y = options.offset.y;
|
||||
str_to_draw.setString("fj"); // Something that has both an ascender and a descender
|
||||
adjust_y -= str_to_draw.getLocalBounds().height;
|
||||
|
||||
@@ -188,11 +185,10 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st
|
||||
}
|
||||
}
|
||||
|
||||
void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,eTextMode mode,TextStyle style, location offset) {
|
||||
void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,eTextMode mode,TextStyle style) {
|
||||
text_params_t params;
|
||||
params.mode = mode;
|
||||
params.style = style;
|
||||
params.offset = offset;
|
||||
win_draw_string(dest_window, dest_rect, str, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ enum class eTextMode {
|
||||
|
||||
std::vector<rectangle> draw_string_hilite(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector<hilite_t> hilites,sf::Color hiliteClr);
|
||||
std::vector<snippet_t> draw_string_sel(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector<hilite_t> hilites,sf::Color hiliteClr);
|
||||
void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,eTextMode mode,TextStyle style, location offset = {0,0});
|
||||
void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,eTextMode mode,TextStyle style);
|
||||
size_t string_length(std::string str, TextStyle style, short* height = nullptr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,7 +45,6 @@ eDrawMode draw_mode = DRAW_TERRAIN;
|
||||
extern short available_dlog_buttons[NUM_DLOG_B];
|
||||
extern bool editing_town;
|
||||
extern cScenario scenario;
|
||||
extern rectangle world_screen;
|
||||
extern sf::Texture bg_gworld;
|
||||
extern rectangle right_buttons[NRSONPAGE];
|
||||
extern rectangle right_scrollbar_rect;
|
||||
|
||||
Reference in New Issue
Block a user