Fix graphics being squished slightly due to the Windows menubar being attached to the window
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "restypes.hpp"
|
||||
#include "boe.menus.h"
|
||||
#include "winutil.h"
|
||||
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern short stat_window;
|
||||
@@ -64,7 +65,6 @@ extern bool show_startup_splash;
|
||||
|
||||
//***********************
|
||||
rectangle menuBarRect;
|
||||
short menuBarHeight;
|
||||
Region originalGrayRgn, newGrayRgn, underBarRgn;
|
||||
|
||||
short terrain_there[9][9]; // this is an optimization variabel. Keeps track of what terrain
|
||||
@@ -164,17 +164,19 @@ location ok_space[4] = {loc(),loc(),loc(),loc()};
|
||||
sf::Image hold_pict;
|
||||
|
||||
void adjust_window_mode() {
|
||||
rectangle r;
|
||||
sf::FloatRect r;
|
||||
sf::ContextSettings winSettings;
|
||||
winSettings.stencilBits = 1;
|
||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||
hideMenuBar();
|
||||
int menubarHeight = getMenubarHeight();
|
||||
|
||||
// TODO: Make display_mode an enum
|
||||
if(display_mode == 5) {
|
||||
ul.x = 14; ul.y = 2;
|
||||
mainPtr.create(sf::VideoMode(605,430,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 - 430) / 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 {
|
||||
@@ -188,7 +190,7 @@ void adjust_window_mode() {
|
||||
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;
|
||||
}
|
||||
redraw_screen(REFRESH_NONE);
|
||||
if(text_sbar != NULL) {
|
||||
|
@@ -7,10 +7,12 @@
|
||||
#include "boe.infodlg.h"
|
||||
#include "boe.consts.h"
|
||||
#include "spell.hpp"
|
||||
#include "winutil.h"
|
||||
|
||||
// Include this last because some #defines in the Windows headers cause compile errors in my headers.
|
||||
// Fortunately they're on symbols not used in this file, so this should work.
|
||||
#include <Windows.h>
|
||||
#include <gl/GL.h>
|
||||
|
||||
// This is the index of each menu on the menubar
|
||||
enum {
|
||||
@@ -45,6 +47,13 @@ void init_menubar() {
|
||||
// Now we have to do a little hack to handle menu messages.
|
||||
// We replace SFML's window procedure with our own, which checks for menu events and then forwards to SFML's procedure.
|
||||
mainProc = SetWindowLongPtr(winHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&menuProc));
|
||||
mainPtr.setActive();
|
||||
// Fix the window's viewport so that everything is drawn correctly
|
||||
sf::Vector2u sz = mainPtr.getSize();
|
||||
double menubarHeight = getMenubarHeight();
|
||||
double usableHeight = sz.y - menubarHeight;
|
||||
sf::View view(sf::FloatRect(0, 0, sz.x, usableHeight));
|
||||
mainPtr.setView(view);
|
||||
}
|
||||
|
||||
void adjust_monst_menu() {
|
||||
@@ -192,11 +201,13 @@ void menu_activate() {
|
||||
}
|
||||
|
||||
void hideMenuBar() {
|
||||
if(menuHandle == NULL) return;
|
||||
SetMenu(mainPtr.getSystemHandle(), NULL);
|
||||
DrawMenuBar(mainPtr.getSystemHandle());
|
||||
}
|
||||
|
||||
void showMenuBar() {
|
||||
if(menuHandle == NULL) return;
|
||||
SetMenu(mainPtr.getSystemHandle(), menuHandle);
|
||||
DrawMenuBar(mainPtr.getSystemHandle());
|
||||
}
|
||||
|
@@ -73,13 +73,7 @@ rectangle::rectangle() : top(0), left(0), right(0), bottom(0) {}
|
||||
rectangle::rectangle(location tl, location br) : top(tl.y), left(tl.x), right(br.x), bottom(br.y) {}
|
||||
rectangle::rectangle(int t, int l, int b, int r) : top(t), left(l), right(r), bottom(b) {}
|
||||
rectangle::rectangle(sf::Texture& texture) : top(0), left(0), right(texture.getSize().x), bottom(texture.getSize().y) {}
|
||||
rectangle::rectangle(sf::RenderTarget& texture) : top(0), left(0), right(texture.getSize().x), bottom(texture.getSize().y) {
|
||||
// This is a hack to work around the menubar in Windows affecting the rect returned by getSize(), despite the available area being unchanged.
|
||||
extern sf::RenderWindow mainPtr;
|
||||
extern int getMenubarHeight();
|
||||
if(&texture == &mainPtr)
|
||||
bottom += getMenubarHeight();
|
||||
}
|
||||
rectangle::rectangle(sf::RenderTarget& texture) : top(0), left(0), right(texture.getSize().x), bottom(texture.getSize().y) {}
|
||||
|
||||
bool rectangle::contains(location p){
|
||||
if(p.y >= top && p.y <= bottom && p.x >= left && p.x <= right)
|
||||
|
@@ -152,7 +152,8 @@ void Initialize(void) {
|
||||
// The window is full screen size, made smaller to make it more visible.
|
||||
//
|
||||
// Size and style obtained from WIND resource #128
|
||||
mainPtr.create(sf::VideoMode(590, 440), "Blades of Exile Character Editor", sf::Style::Titlebar | sf::Style::Close);
|
||||
int height = 440 + getMenubarHeight();
|
||||
mainPtr.create(sf::VideoMode(590, height), "Blades of Exile Character Editor", sf::Style::Titlebar | sf::Style::Close);
|
||||
init_menubar();
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include "Resource.h"
|
||||
#include "universe.h"
|
||||
#include "winutil.h"
|
||||
|
||||
// Include this last because some #defines in the Windows headers cause compile errors in my headers.
|
||||
// Fortunately they're on symbols not used in this file, so this should work.
|
||||
@@ -35,6 +36,12 @@ void init_menubar() {
|
||||
// Now we have to do a little hack to handle menu messages.
|
||||
// We replace SFML's window procedure with our own, which checks for menu events and then forwards to SFML's procedure.
|
||||
mainProc = SetWindowLongPtr(winHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&menuProc));
|
||||
// Fix the window's viewport so that everything is drawn correctly
|
||||
sf::Vector2u sz = mainPtr.getSize();
|
||||
double menubarHeight = getMenubarHeight();
|
||||
double usableHeight = sz.y - menubarHeight;
|
||||
sf::View view(sf::FloatRect(0, 0, sz.x, usableHeight));
|
||||
mainPtr.setView(view);
|
||||
}
|
||||
|
||||
void update_item_menu() {
|
||||
|
@@ -432,11 +432,8 @@ void draw_main_screen() {
|
||||
}
|
||||
|
||||
void draw_lb() {
|
||||
rectangle temp_rect(mainPtr);
|
||||
short i;
|
||||
|
||||
temp_rect.right = RIGHT_AREA_UL_X - 2;
|
||||
tileImage(mainPtr,temp_rect,bg[20]);
|
||||
for(i = 0; i < NLS; i++)
|
||||
draw_lb_slot(i,0);
|
||||
}
|
||||
|
@@ -165,8 +165,9 @@ void Initialize(void) {
|
||||
rectangle windRect;
|
||||
windRect.width() = mode.width;
|
||||
windRect.height() = mode.height;
|
||||
int height = 420 + getMenubarHeight();
|
||||
|
||||
windRect.inset((windRect.right - 584) / 2,(windRect.bottom - 420) / 2);
|
||||
windRect.inset((windRect.right - 584) / 2,(windRect.bottom - height) / 2);
|
||||
windRect.offset(0,18);
|
||||
// TODO: I think it should have a close button as well
|
||||
mainPtr.create(sf::VideoMode(windRect.width(), windRect.height()), "Blades of Exile Scenario Editor", sf::Style::Titlebar);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include "Resource.h"
|
||||
#include "scenario.h"
|
||||
#include "winutil.h"
|
||||
|
||||
// Include this last because some #defines in the Windows headers cause compile errors in my headers.
|
||||
// Fortunately they're on symbols not used in this file, so this should work.
|
||||
@@ -36,6 +37,12 @@ void init_menubar() {
|
||||
// Now we have to do a little hack to handle menu messages.
|
||||
// We replace SFML's window procedure with our own, which checks for menu events and then forwards to SFML's procedure.
|
||||
mainProc = SetWindowLongPtr(winHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&menuProc));
|
||||
// Fix the window's viewport so that everything is drawn correctly
|
||||
sf::Vector2u sz = mainPtr.getSize();
|
||||
double menubarHeight = getMenubarHeight();
|
||||
double usableHeight = sz.y - menubarHeight;
|
||||
sf::View view(sf::FloatRect(0, 0, sz.x, usableHeight));
|
||||
mainPtr.setView(view);
|
||||
}
|
||||
|
||||
void update_item_menu() {
|
||||
|
Reference in New Issue
Block a user