Fix Windows build
This commit is contained in:
@@ -2027,7 +2027,8 @@ bool handle_keystroke(sf::Event& event){
|
|||||||
break;
|
break;
|
||||||
case 'a': // Show automap
|
case 'a': // Show automap
|
||||||
if(overall_mode < MODE_TALK_TOWN) {
|
if(overall_mode < MODE_TALK_TOWN) {
|
||||||
pass_point = mainPtr.mapCoordsToPixel({overall_mode == MODE_OUTDOORS ? 180 : 221, 405}, mainView);
|
pass_point = loc(overall_mode == MODE_OUTDOORS ? 180 : 221, 405);
|
||||||
|
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||||
pass_event.mouseButton.x = pass_point.x;
|
pass_event.mouseButton.x = pass_point.x;
|
||||||
pass_event.mouseButton.y = pass_point.y;
|
pass_event.mouseButton.y = pass_point.y;
|
||||||
are_done = handle_action(pass_event);
|
are_done = handle_action(pass_event);
|
||||||
@@ -2045,7 +2046,8 @@ bool handle_keystroke(sf::Event& event){
|
|||||||
|
|
||||||
case 'b': case 'L': // Bash door, pick lock
|
case 'b': case 'L': // Bash door, pick lock
|
||||||
if(overall_mode == MODE_TOWN || overall_mode == MODE_BASH_TOWN) {
|
if(overall_mode == MODE_TOWN || overall_mode == MODE_BASH_TOWN) {
|
||||||
pass_point = mainPtr.mapCoordsToPixel({chr == 'b' ? 1002 : 1003, 0}, mainView);
|
pass_point = loc(chr == 'b' ? 1002 : 1003, 0);
|
||||||
|
pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView);
|
||||||
pass_event.mouseButton.x = pass_point.x;
|
pass_event.mouseButton.x = pass_point.x;
|
||||||
pass_event.mouseButton.y = pass_point.y;
|
pass_event.mouseButton.y = pass_point.y;
|
||||||
are_done = handle_action(pass_event);
|
are_done = handle_action(pass_event);
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ void adjust_window_mode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rectangle windRect(mainPtr);
|
rectangle windRect(mainPtr);
|
||||||
|
#ifdef _WIN32
|
||||||
|
windRect.height() -= menubarHeight;
|
||||||
|
#endif
|
||||||
if(mode == 0) {
|
if(mode == 0) {
|
||||||
ul.x = (windRect.right - width) / 2;
|
ul.x = (windRect.right - width) / 2;
|
||||||
ul.y = (windRect.bottom - height) / 2;
|
ul.y = (windRect.bottom - height) / 2;
|
||||||
@@ -157,13 +160,17 @@ void adjust_window_mode() {
|
|||||||
ul.x = 10;
|
ul.x = 10;
|
||||||
else ul.x = windRect.right - width - 10;
|
else ul.x = windRect.right - width - 10;
|
||||||
if(mode == 1 || mode == 2)
|
if(mode == 1 || mode == 2)
|
||||||
ul.y = 28 + menubarHeight;
|
ul.y = 28
|
||||||
|
#ifndef _WIN32
|
||||||
|
+ menubarHeight;
|
||||||
|
#endif
|
||||||
|
;
|
||||||
else ul.y = windRect.bottom - height - 28;
|
else ul.y = windRect.bottom - height - 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the viewport for the game UI
|
// Initialize the viewport for the game UI
|
||||||
mainView.setSize(width, height);
|
mainView.setSize(width, height);
|
||||||
mainView.setCenter(/*ul.x +*/ width / 2, /*ul.y +*/ height / 2);
|
mainView.setCenter(width / 2, height / 2);
|
||||||
sf::FloatRect mainPort;
|
sf::FloatRect mainPort;
|
||||||
mainPort.left = float(ul.x) / windRect.width();
|
mainPort.left = float(ul.x) / windRect.width();
|
||||||
mainPort.top = float(ul.y) / windRect.height();
|
mainPort.top = float(ul.y) / windRect.height();
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ static bool save_prefs(fs::path fpath) {
|
|||||||
fout << kv.first << " = " << std::boolalpha << boost::any_cast<bool>(kv.second) << std::endl;
|
fout << kv.first << " = " << std::boolalpha << boost::any_cast<bool>(kv.second) << std::endl;
|
||||||
else if(kv.second.type() == typeid(int))
|
else if(kv.second.type() == typeid(int))
|
||||||
fout << kv.first << " = " << boost::any_cast<int>(kv.second) << std::endl;
|
fout << kv.first << " = " << boost::any_cast<int>(kv.second) << std::endl;
|
||||||
|
else if(kv.second.type() == typeid(double))
|
||||||
|
fout << kv.first << " = " << boost::any_cast<double>(kv.second) << std::endl;
|
||||||
else printf("Warning: Unknown preference value type, skipping...\n");
|
else printf("Warning: Unknown preference value type, skipping...\n");
|
||||||
if(!fout) {
|
if(!fout) {
|
||||||
perror("Error writing preferences");
|
perror("Error writing preferences");
|
||||||
@@ -129,7 +131,11 @@ static bool load_prefs(fs::path fpath) {
|
|||||||
iarray vals;
|
iarray vals;
|
||||||
while(arr_vals >> i) vals.push_back(i);
|
while(arr_vals >> i) vals.push_back(i);
|
||||||
temp_prefs[key] = vals;
|
temp_prefs[key] = vals;
|
||||||
} else temp_prefs[key] = boost::lexical_cast<int>(val);
|
} else try {
|
||||||
|
temp_prefs[key] = boost::lexical_cast<int>(val);
|
||||||
|
} catch(boost::bad_lexical_cast&) {
|
||||||
|
temp_prefs[key] = boost::lexical_cast<double>(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prefs.swap(temp_prefs);
|
prefs.swap(temp_prefs);
|
||||||
return prefsLoaded = true;
|
return prefsLoaded = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user