Scroll wheel support
- All areas with scroll wheels can be scrolled using the scroll wheel if the mouse is in the area - In addition, the terrain view is scrollable with the scroll wheel (hold Control for horizontal scrolling) - The above applies in the game too, whenever the scroll arrows are visible
This commit is contained in:
@@ -80,6 +80,7 @@ long dummy;
|
|||||||
short store_selling_values[8] = {0,0,0,0,0,0,0,0};
|
short store_selling_values[8] = {0,0,0,0,0,0,0,0};
|
||||||
extern cShop active_shop;
|
extern cShop active_shop;
|
||||||
|
|
||||||
|
extern rectangle shop_frame;
|
||||||
extern short cen_x, cen_y, stat_window;//,pc_moves[6];
|
extern short cen_x, cen_y, stat_window;//,pc_moves[6];
|
||||||
extern bool give_delays;
|
extern bool give_delays;
|
||||||
extern eGameMode overall_mode;
|
extern eGameMode overall_mode;
|
||||||
@@ -1259,8 +1260,7 @@ bool handle_action(sf::Event event) {
|
|||||||
// MARK: End: click in terrain
|
// MARK: End: click in terrain
|
||||||
|
|
||||||
// MARK: Begin: Screen shift
|
// MARK: Begin: Screen shift
|
||||||
if(overall_mode == MODE_SPELL_TARGET || overall_mode == MODE_FIRING || overall_mode == MODE_THROWING
|
if(scrollableModes.count(overall_mode)) {
|
||||||
|| overall_mode == MODE_FANCY_TARGET || overall_mode == MODE_LOOK_COMBAT || overall_mode == MODE_LOOK_TOWN) {
|
|
||||||
if(the_point.in(border_rect[0]) && center.y > univ.town->in_town_rect.top && center.y > 4) {
|
if(the_point.in(border_rect[0]) && center.y > univ.town->in_town_rect.top && center.y > 4) {
|
||||||
center.y--;
|
center.y--;
|
||||||
need_redraw = true;
|
need_redraw = true;
|
||||||
@@ -2152,6 +2152,33 @@ bool handle_keystroke(sf::Event& event){
|
|||||||
return are_done;
|
return are_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
fill_rect(mainPtr, world_screen, sf::Color::Magenta);
|
||||||
|
location pos(event.mouseWheel.x, event.mouseWheel.y);
|
||||||
|
int amount = event.mouseWheel.delta;
|
||||||
|
if(item_sbar->isVisible() && pos.in(status_panel_rect)) {
|
||||||
|
item_sbar->setPosition(item_sbar->getPosition() - amount);
|
||||||
|
redraw_screen(REFRESH_INVEN);
|
||||||
|
} else if(text_sbar->isVisible() && pos.in(text_panel_rect)) {
|
||||||
|
text_sbar->setPosition(text_sbar->getPosition() - amount);
|
||||||
|
redraw_screen(REFRESH_TRANS);
|
||||||
|
} else if(shop_sbar->isVisible() && pos.in(shop_frame)) {
|
||||||
|
shop_sbar->setPosition(shop_sbar->getPosition() - amount);
|
||||||
|
redraw_screen(REFRESH_DLOG);
|
||||||
|
} else if(scrollableModes.count(overall_mode) && pos.in(world_screen)) {
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::RControl))
|
||||||
|
center.x -= amount;
|
||||||
|
else center.y -= amount;
|
||||||
|
redraw_screen(REFRESH_TERRAIN);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void do_load() {
|
void do_load() {
|
||||||
fs::path file_to_load = nav_get_party();
|
fs::path file_to_load = nav_get_party();
|
||||||
if(file_to_load.empty()) return;
|
if(file_to_load.empty()) return;
|
||||||
|
@@ -14,6 +14,7 @@ bool someone_awake();
|
|||||||
void handle_menu_spell(short spell_picked,short spell_type) ;
|
void handle_menu_spell(short spell_picked,short spell_type) ;
|
||||||
void initiate_outdoor_combat(short i);
|
void initiate_outdoor_combat(short i);
|
||||||
bool handle_keystroke(sf::Event& event);
|
bool handle_keystroke(sf::Event& event);
|
||||||
|
bool handle_scroll(sf::Event& event);
|
||||||
void do_load();
|
void do_load();
|
||||||
void post_load();
|
void post_load();
|
||||||
void do_save(short mode);
|
void do_save(short mode);
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
#ifndef BOE_GAME_CONSTS_H
|
#ifndef BOE_GAME_CONSTS_H
|
||||||
#define BOE_GAME_CONSTS_H
|
#define BOE_GAME_CONSTS_H
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file contain numerous constans in form of #defines.
|
This file contain numerous constans in form of #defines.
|
||||||
Almost all of these constants cannot be changed because
|
Almost all of these constants cannot be changed because
|
||||||
@@ -80,6 +82,15 @@ enum eGameMode {
|
|||||||
MODE_CUTSCENE = 51, // for future use
|
MODE_CUTSCENE = 51, // for future use
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const std::set<eGameMode> scrollableModes = {
|
||||||
|
MODE_SPELL_TARGET,
|
||||||
|
MODE_FIRING,
|
||||||
|
MODE_THROWING,
|
||||||
|
MODE_FANCY_TARGET,
|
||||||
|
MODE_LOOK_COMBAT,
|
||||||
|
MODE_LOOK_TOWN
|
||||||
|
};
|
||||||
|
|
||||||
enum eStatMode {
|
enum eStatMode {
|
||||||
MODE_INVEN = 0,
|
MODE_INVEN = 0,
|
||||||
MODE_SHOP = 1,
|
MODE_SHOP = 1,
|
||||||
|
@@ -1548,8 +1548,7 @@ void draw_pointing_arrows() {
|
|||||||
rectangle{346,100,354,108},rectangle{346,170,354,178},rectangle{140,274,148,282},rectangle{212,274,220,282}};
|
rectangle{346,100,354,108},rectangle{346,170,354,178},rectangle{140,274,148,282},rectangle{212,274,220,282}};
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
if((monsters_going) || /*(overall_mode <= MODE_TOWN) ||*/ (overall_mode <= MODE_COMBAT)
|
if(monsters_going || !scrollableModes.count(overall_mode))
|
||||||
|| (overall_mode == MODE_LOOK_OUTDOORS))
|
|
||||||
return;
|
return;
|
||||||
for(i = 0; i < 4; i++) {
|
for(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],ul,sf::BlendAlpha);
|
||||||
|
@@ -259,6 +259,11 @@ void Handle_One_Event() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case sf::Event::MouseWheelMoved:
|
||||||
|
if(flushingInput) return;
|
||||||
|
handle_scroll(event);
|
||||||
|
break;
|
||||||
|
|
||||||
case sf::Event::GainedFocus:
|
case sf::Event::GainedFocus:
|
||||||
Handle_Update();
|
Handle_Update();
|
||||||
makeFrontWindow(mainPtr);
|
makeFrontWindow(mainPtr);
|
||||||
|
@@ -40,8 +40,6 @@ extern short had_text_freeze;
|
|||||||
extern eStatMode stat_screen_mode;
|
extern eStatMode stat_screen_mode;
|
||||||
|
|
||||||
// graphics globals
|
// graphics globals
|
||||||
extern rectangle status_panel_rect,status_panel_title_rect;
|
|
||||||
extern rectangle text_panel_rect;
|
|
||||||
extern short which_combat_type,stat_window;
|
extern short which_combat_type,stat_window;
|
||||||
extern eGameMode overall_mode;
|
extern eGameMode overall_mode;
|
||||||
extern sf::RenderWindow mainPtr;
|
extern sf::RenderWindow mainPtr;
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
void force_town_enter(short which_town,location where_start);
|
void force_town_enter(short which_town,location where_start);
|
||||||
void start_town_mode(short which_town, short entry_dir);
|
void start_town_mode(short which_town, short entry_dir);
|
||||||
void terrain_under_rentar();
|
|
||||||
location end_town_mode(short switching_level,location destination); // returns new party location
|
location end_town_mode(short switching_level,location destination); // returns new party location
|
||||||
void handle_leave_town_specials(short town_number, short which_spec,location start_loc) ;
|
void handle_leave_town_specials(short town_number, short which_spec,location start_loc) ;
|
||||||
void handle_town_specials(short town_number, bool town_dead,location start_loc) ;
|
void handle_town_specials(short town_number, bool town_dead,location start_loc) ;
|
||||||
|
@@ -59,7 +59,7 @@ cTown::cItem store_place_item;
|
|||||||
short flood_count = 0;
|
short flood_count = 0;
|
||||||
|
|
||||||
rectangle terrain_rects[256],terrain_rect_base = {0,0,16,16},command_rects[21];
|
rectangle terrain_rects[256],terrain_rect_base = {0,0,16,16},command_rects[21];
|
||||||
|
extern rectangle terrain_buttons_rect;
|
||||||
|
|
||||||
extern short cen_x, cen_y, cur_town;
|
extern short cen_x, cen_y, cur_town;
|
||||||
extern eScenMode overall_mode;
|
extern eScenMode overall_mode;
|
||||||
@@ -1515,6 +1515,30 @@ void handle_keystroke(sf::Event event) {
|
|||||||
mouse_button_held = false;
|
mouse_button_held = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool handle_scroll(sf::Event& event) {
|
||||||
|
rectangle pal_rect = terrain_buttons_rect, right_area_rect = {0,0,RIGHT_AREA_HEIGHT,RIGHT_AREA_WIDTH};
|
||||||
|
right_area_rect.offset(RIGHT_AREA_UL_X, RIGHT_AREA_UL_Y);
|
||||||
|
pal_rect.offset(RIGHT_AREA_UL_X,RIGHT_AREA_UL_Y);
|
||||||
|
pal_rect.height() = 16 * 17 + 2;
|
||||||
|
fill_rect(mainPtr, right_area_rect, sf::Color::Magenta);
|
||||||
|
location pos(event.mouseWheel.x, event.mouseWheel.y);
|
||||||
|
int amount = event.mouseWheel.delta;
|
||||||
|
if(right_sbar->isVisible() && pos.in(right_area_rect)) {
|
||||||
|
right_sbar->setPosition(right_sbar->getPosition() - amount);
|
||||||
|
redraw_screen();
|
||||||
|
} else if(pal_sbar->isVisible() && pos.in(pal_rect)) {
|
||||||
|
pal_sbar->setPosition(pal_sbar->getPosition() - amount);
|
||||||
|
set_up_terrain_buttons(false);
|
||||||
|
redraw_screen();
|
||||||
|
} else if(overall_mode < MODE_MAIN_SCREEN && pos.in(world_screen)) {
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::RControl))
|
||||||
|
cen_x -= amount;
|
||||||
|
else cen_y -= amount;
|
||||||
|
redraw_screen();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void shy_change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability) {
|
void shy_change_circle_terrain(location center,short radius,ter_num_t terrain_type,short probability) {
|
||||||
// prob is 0 - 20, 0 no, 20 always
|
// prob is 0 - 20, 0 no, 20 always
|
||||||
location l;
|
location l;
|
||||||
|
@@ -5,6 +5,7 @@ void flash_rect(rectangle to_flash);
|
|||||||
void swap_terrain();
|
void swap_terrain();
|
||||||
void set_new_terrain(ter_num_t selected_terrain);
|
void set_new_terrain(ter_num_t selected_terrain);
|
||||||
void handle_keystroke(sf::Event event);
|
void handle_keystroke(sf::Event event);
|
||||||
|
bool handle_scroll(sf::Event& event);
|
||||||
void get_wandering_monst();
|
void get_wandering_monst();
|
||||||
void get_town_info();
|
void get_town_info();
|
||||||
void get_sign_resource();
|
void get_sign_resource();
|
||||||
|
@@ -16,7 +16,6 @@ extern rectangle right_sbar_rect;
|
|||||||
rectangle left_button[NLS];
|
rectangle left_button[NLS];
|
||||||
extern rectangle right_buttons[NRSONPAGE];
|
extern rectangle right_buttons[NRSONPAGE];
|
||||||
rectangle right_scrollbar_rect;
|
rectangle right_scrollbar_rect;
|
||||||
rectangle right_area_rect;
|
|
||||||
extern short current_rs_top;
|
extern short current_rs_top;
|
||||||
|
|
||||||
bool left_buttons_active = 1,right_buttons_active = 0;
|
bool left_buttons_active = 1,right_buttons_active = 0;
|
||||||
|
@@ -48,7 +48,6 @@ extern sf::Texture bg_gworld;
|
|||||||
extern rectangle left_button[NLS];
|
extern rectangle left_button[NLS];
|
||||||
extern rectangle right_buttons[NRSONPAGE];
|
extern rectangle right_buttons[NRSONPAGE];
|
||||||
extern rectangle right_scrollbar_rect;
|
extern rectangle right_scrollbar_rect;
|
||||||
extern rectangle right_area_rect;
|
|
||||||
extern std::shared_ptr<cScrollbar> right_sbar, pal_sbar;
|
extern std::shared_ptr<cScrollbar> right_sbar, pal_sbar;
|
||||||
|
|
||||||
extern bool left_buttons_active,right_buttons_active;
|
extern bool left_buttons_active,right_buttons_active;
|
||||||
|
@@ -169,6 +169,10 @@ void Handle_One_Event() {
|
|||||||
update_mouse_spot(loc(event.mouseMove.x,event.mouseMove.y));
|
update_mouse_spot(loc(event.mouseMove.x,event.mouseMove.y));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case sf::Event::MouseWheelMoved:
|
||||||
|
handle_scroll(event);
|
||||||
|
break;
|
||||||
|
|
||||||
case sf::Event::MouseButtonReleased:
|
case sf::Event::MouseButtonReleased:
|
||||||
mouse_button_held = false;
|
mouse_button_held = false;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user