mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 02:15:32 +00:00
Remember window positions
This commit is contained in:
parent
5f1878eb54
commit
f695deb29d
9 changed files with 172 additions and 34 deletions
|
@ -37,10 +37,6 @@ namespace MWGui
|
|||
, mPreviewDirty(true)
|
||||
, mDragAndDrop(dragAndDrop)
|
||||
, mSelectedItem(-1)
|
||||
, mPositionInventory(0, 342, 498, 258)
|
||||
, mPositionContainer(0, 342, 498, 258)
|
||||
, mPositionCompanion(0, 342, 498, 258)
|
||||
, mPositionBarter(0, 342, 498, 258)
|
||||
, mGuiMode(GM_Inventory)
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
|
||||
|
@ -71,8 +67,19 @@ namespace MWGui
|
|||
|
||||
mFilterAll->setStateSelected(true);
|
||||
|
||||
setCoord(mPositionInventory.left, mPositionInventory.top, mPositionInventory.width, mPositionInventory.height);
|
||||
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
||||
setGuiMode(mGuiMode);
|
||||
|
||||
adjustPanes();
|
||||
}
|
||||
|
||||
void InventoryWindow::adjustPanes()
|
||||
{
|
||||
const float aspect = 0.5; // fixed aspect ratio for the left pane
|
||||
mLeftPane->setSize( (mMainWidget->getSize().height-44) * aspect, mMainWidget->getSize().height-44 );
|
||||
mRightPane->setCoord( mLeftPane->getPosition().left + (mMainWidget->getSize().height-44) * aspect + 4,
|
||||
mRightPane->getPosition().top,
|
||||
mMainWidget->getSize().width - 12 - (mMainWidget->getSize().height-44) * aspect - 15,
|
||||
mMainWidget->getSize().height-44 );
|
||||
}
|
||||
|
||||
void InventoryWindow::updatePlayer()
|
||||
|
@ -87,27 +94,36 @@ namespace MWGui
|
|||
|
||||
void InventoryWindow::setGuiMode(GuiMode mode)
|
||||
{
|
||||
std::string setting = "inventory";
|
||||
mGuiMode = mode;
|
||||
switch(mode) {
|
||||
case GM_Container:
|
||||
setPinButtonVisible(false);
|
||||
mMainWidget->setCoord(mPositionContainer);
|
||||
setting += " container";
|
||||
break;
|
||||
case GM_Companion:
|
||||
setPinButtonVisible(false);
|
||||
mMainWidget->setCoord(mPositionCompanion);
|
||||
setting += " companion";
|
||||
break;
|
||||
case GM_Barter:
|
||||
setPinButtonVisible(false);
|
||||
mMainWidget->setCoord(mPositionBarter);
|
||||
setting += " barter";
|
||||
break;
|
||||
case GM_Inventory:
|
||||
default:
|
||||
setPinButtonVisible(true);
|
||||
mMainWidget->setCoord(mPositionInventory);
|
||||
break;
|
||||
}
|
||||
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntPoint pos (Settings::Manager::getFloat(setting + " x", "Windows") * viewSize.width,
|
||||
Settings::Manager::getFloat(setting + " y", "Windows") * viewSize.height);
|
||||
MyGUI::IntSize size (Settings::Manager::getFloat(setting + " w", "Windows") * viewSize.width,
|
||||
Settings::Manager::getFloat(setting + " h", "Windows") * viewSize.height);
|
||||
mMainWidget->setPosition(pos);
|
||||
mMainWidget->setSize(size);
|
||||
adjustPanes();
|
||||
mPreviewDirty = true;
|
||||
}
|
||||
|
||||
TradeItemModel* InventoryWindow::getTradeModel()
|
||||
|
@ -256,32 +272,37 @@ namespace MWGui
|
|||
mItemView->update();
|
||||
|
||||
notifyContentChanged();
|
||||
adjustPanes();
|
||||
}
|
||||
|
||||
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
||||
{
|
||||
const float aspect = 0.5; // fixed aspect ratio for the left pane
|
||||
mLeftPane->setSize( (_sender->getSize().height-44) * aspect, _sender->getSize().height-44 );
|
||||
mRightPane->setCoord( mLeftPane->getPosition().left + (_sender->getSize().height-44) * aspect + 4,
|
||||
mRightPane->getPosition().top,
|
||||
_sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15,
|
||||
_sender->getSize().height-44 );
|
||||
|
||||
adjustPanes();
|
||||
std::string setting = "inventory";
|
||||
switch(mGuiMode) {
|
||||
case GM_Container:
|
||||
mPositionContainer = _sender->getCoord();
|
||||
setting += " container";
|
||||
break;
|
||||
case GM_Companion:
|
||||
mPositionCompanion = _sender->getCoord();
|
||||
setting += " companion";
|
||||
break;
|
||||
case GM_Barter:
|
||||
mPositionBarter = _sender->getCoord();
|
||||
setting += " barter";
|
||||
break;
|
||||
case GM_Inventory:
|
||||
default:
|
||||
mPositionInventory = _sender->getCoord();
|
||||
break;
|
||||
}
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
float x = _sender->getPosition().left / float(viewSize.width);
|
||||
float y = _sender->getPosition().top / float(viewSize.height);
|
||||
float w = _sender->getSize().width / float(viewSize.width);
|
||||
float h = _sender->getSize().height / float(viewSize.height);
|
||||
Settings::Manager::setFloat(setting + " x", "Windows", x);
|
||||
Settings::Manager::setFloat(setting + " y", "Windows", y);
|
||||
Settings::Manager::setFloat(setting + " w", "Windows", w);
|
||||
Settings::Manager::setFloat(setting + " h", "Windows", h);
|
||||
|
||||
if (mMainWidget->getSize().width != mLastXSize || mMainWidget->getSize().height != mLastYSize)
|
||||
{
|
||||
mLastXSize = mMainWidget->getSize().width;
|
||||
|
|
|
@ -76,11 +76,6 @@ namespace MWGui
|
|||
MyGUI::Button* mFilterMagic;
|
||||
MyGUI::Button* mFilterMisc;
|
||||
|
||||
MyGUI::IntCoord mPositionInventory;
|
||||
MyGUI::IntCoord mPositionContainer;
|
||||
MyGUI::IntCoord mPositionCompanion;
|
||||
MyGUI::IntCoord mPositionBarter;
|
||||
|
||||
GuiMode mGuiMode;
|
||||
|
||||
int mLastXSize;
|
||||
|
@ -105,6 +100,8 @@ namespace MWGui
|
|||
|
||||
void updateEncumbranceBar();
|
||||
void notifyContentChanged();
|
||||
|
||||
void adjustPanes();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -154,10 +154,6 @@ namespace MWGui
|
|||
size.width = mFixedWidth;
|
||||
size.height = 100; // dummy
|
||||
|
||||
MyGUI::IntCoord coord;
|
||||
coord.left = 10; // dummy
|
||||
coord.top = 10; // dummy
|
||||
|
||||
mMessageWidget->setSize(size);
|
||||
|
||||
MyGUI::IntSize textSize = mMessageWidget->getTextSize();
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace MWGui
|
|||
void setBounty (int bounty) { if (bounty != mBounty) mChanged = true; this->mBounty = bounty; }
|
||||
void updateSkillArea();
|
||||
|
||||
virtual void open() { onWindowResize(static_cast<MyGUI::Window*>(mMainWidget)); }
|
||||
|
||||
private:
|
||||
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||
|
|
|
@ -203,16 +203,22 @@ namespace MWGui
|
|||
mRecharge = new Recharge();
|
||||
mMenu = new MainMenu(w,h);
|
||||
mMap = new MapWindow("");
|
||||
trackWindow(mMap, "map");
|
||||
mStatsWindow = new StatsWindow();
|
||||
trackWindow(mStatsWindow, "stats");
|
||||
mConsole = new Console(w,h, mConsoleOnlyScripts);
|
||||
trackWindow(mConsole, "console");
|
||||
mJournal = JournalWindow::create(JournalViewModel::create ());
|
||||
mMessageBoxManager = new MessageBoxManager();
|
||||
mInventoryWindow = new InventoryWindow(mDragAndDrop);
|
||||
mTradeWindow = new TradeWindow();
|
||||
trackWindow(mTradeWindow, "barter");
|
||||
mSpellBuyingWindow = new SpellBuyingWindow();
|
||||
mTravelWindow = new TravelWindow();
|
||||
mDialogueWindow = new DialogueWindow();
|
||||
trackWindow(mDialogueWindow, "dialogue");
|
||||
mContainerWindow = new ContainerWindow(mDragAndDrop);
|
||||
trackWindow(mContainerWindow, "container");
|
||||
mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop);
|
||||
mToolTips = new ToolTips();
|
||||
mScrollWindow = new ScrollWindow();
|
||||
|
@ -221,7 +227,9 @@ namespace MWGui
|
|||
mSettingsWindow = new SettingsWindow();
|
||||
mConfirmationDialog = new ConfirmationDialog();
|
||||
mAlchemyWindow = new AlchemyWindow();
|
||||
trackWindow(mAlchemyWindow, "alchemy");
|
||||
mSpellWindow = new SpellWindow();
|
||||
trackWindow(mSpellWindow, "spells");
|
||||
mQuickKeysMenu = new QuickKeysMenu();
|
||||
mLevelupDialog = new LevelupDialog();
|
||||
mWaitDialog = new WaitDialog();
|
||||
|
@ -232,6 +240,7 @@ namespace MWGui
|
|||
mRepair = new Repair();
|
||||
mSoulgemDialog = new SoulgemDialog(mMessageBoxManager);
|
||||
mCompanionWindow = new CompanionWindow(mDragAndDrop, mMessageBoxManager);
|
||||
trackWindow(mCompanionWindow, "companion");
|
||||
|
||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
|
||||
|
||||
|
@ -926,6 +935,17 @@ namespace MWGui
|
|||
mLoadingScreen->onResChange (x,y);
|
||||
if (!mHud)
|
||||
return; // UI not initialized yet
|
||||
|
||||
for (std::map<MyGUI::Window*, std::string>::iterator it = mTrackedWindows.begin(); it != mTrackedWindows.end(); ++it)
|
||||
{
|
||||
MyGUI::IntPoint pos (Settings::Manager::getFloat(it->second + " x", "Windows") * x,
|
||||
Settings::Manager::getFloat(it->second+ " y", "Windows") * y);
|
||||
MyGUI::IntSize size (Settings::Manager::getFloat(it->second + " w", "Windows") * x,
|
||||
Settings::Manager::getFloat(it->second + " h", "Windows") * y);
|
||||
it->first->setPosition(pos);
|
||||
it->first->setSize(size);
|
||||
}
|
||||
|
||||
mHud->onResChange(x, y);
|
||||
mConsole->onResChange(x, y);
|
||||
mMenu->onResChange(x, y);
|
||||
|
@ -1364,4 +1384,35 @@ namespace MWGui
|
|||
return mCursorVisible;
|
||||
}
|
||||
|
||||
void WindowManager::trackWindow(OEngine::GUI::Layout *layout, const std::string &name)
|
||||
{
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntPoint pos (Settings::Manager::getFloat(name + " x", "Windows") * viewSize.width,
|
||||
Settings::Manager::getFloat(name + " y", "Windows") * viewSize.height);
|
||||
MyGUI::IntSize size (Settings::Manager::getFloat(name + " w", "Windows") * viewSize.width,
|
||||
Settings::Manager::getFloat(name + " h", "Windows") * viewSize.height);
|
||||
layout->mMainWidget->setPosition(pos);
|
||||
layout->mMainWidget->setSize(size);
|
||||
|
||||
MyGUI::Window* window = dynamic_cast<MyGUI::Window*>(layout->mMainWidget);
|
||||
if (!window)
|
||||
throw std::runtime_error("Attempting to track size of a non-resizable window");
|
||||
window->eventWindowChangeCoord += MyGUI::newDelegate(this, &WindowManager::onWindowChangeCoord);
|
||||
mTrackedWindows[window] = name;
|
||||
}
|
||||
|
||||
void WindowManager::onWindowChangeCoord(MyGUI::Window *_sender)
|
||||
{
|
||||
std::string setting = mTrackedWindows[_sender];
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
float x = _sender->getPosition().left / float(viewSize.width);
|
||||
float y = _sender->getPosition().top / float(viewSize.height);
|
||||
float w = _sender->getSize().width / float(viewSize.width);
|
||||
float h = _sender->getSize().height / float(viewSize.height);
|
||||
Settings::Manager::setFloat(setting + " x", "Windows", x);
|
||||
Settings::Manager::setFloat(setting + " y", "Windows", y);
|
||||
Settings::Manager::setFloat(setting + " w", "Windows", w);
|
||||
Settings::Manager::setFloat(setting + " h", "Windows", h);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace MyGUI
|
|||
{
|
||||
class Gui;
|
||||
class Widget;
|
||||
class Window;
|
||||
class UString;
|
||||
}
|
||||
|
||||
|
@ -283,6 +284,10 @@ namespace MWGui
|
|||
private:
|
||||
bool mConsoleOnlyScripts;
|
||||
|
||||
std::map<MyGUI::Window*, std::string> mTrackedWindows;
|
||||
void trackWindow(OEngine::GUI::Layout* layout, const std::string& name);
|
||||
void onWindowChangeCoord(MyGUI::Window* _sender);
|
||||
|
||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||
OEngine::Render::OgreRenderer *mRendering;
|
||||
HUD *mHud;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="ExposedWindow" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main">
|
||||
<Property key="MinSize" value="500 342"/>
|
||||
<Property key="MinSize" value="300 200"/>
|
||||
|
||||
<Widget type="Widget" skin="" name="LeftPane" position="0 0 220 342">
|
||||
|
||||
|
|
|
@ -169,3 +169,69 @@ ui y multiplier = 1.0
|
|||
[Game]
|
||||
# Always use the most powerful attack when striking with a weapon (chop, slash or thrust)
|
||||
best attack = false
|
||||
|
||||
[Windows]
|
||||
inventory x = 0
|
||||
inventory y = 0.4275
|
||||
inventory w = 0.6225
|
||||
inventory h = 0.5725
|
||||
|
||||
inventory container x = 0
|
||||
inventory container y = 0.4275
|
||||
inventory container w = 0.6225
|
||||
inventory container h = 0.5725
|
||||
|
||||
inventory barter x = 0
|
||||
inventory barter y = 0.4275
|
||||
inventory barter w = 0.6225
|
||||
inventory barter h = 0.5725
|
||||
|
||||
inventory companion x = 0
|
||||
inventory companion y = 0.4275
|
||||
inventory companion w = 0.6225
|
||||
inventory companion h = 0.5725
|
||||
|
||||
container x = 0.25
|
||||
container y = 0
|
||||
container w = 0.75
|
||||
container h = 0.375
|
||||
|
||||
companion x = 0.25
|
||||
companion y = 0
|
||||
companion w = 0.75
|
||||
companion h = 0.375
|
||||
|
||||
map x = 0.625
|
||||
map y = 0
|
||||
map w = 0.375
|
||||
map h = 0.5725
|
||||
|
||||
barter x = 0.25
|
||||
barter y = 0
|
||||
barter w = 0.75
|
||||
barter h = 0.375
|
||||
|
||||
alchemy x = 0.25
|
||||
alchemy y = 0.25
|
||||
alchemy w = 0.5
|
||||
alchemy h = 0.5
|
||||
|
||||
stats x = 0
|
||||
stats y = 0
|
||||
stats w = 0.375
|
||||
stats h = 0.4275
|
||||
|
||||
spells x = 0.3775
|
||||
spells y = 0.4275
|
||||
spells w = 0.375
|
||||
spells h = 0.5725
|
||||
|
||||
console x = 0
|
||||
console y = 0
|
||||
console w = 1
|
||||
console h = 0.5
|
||||
|
||||
dialogue h = 0.810
|
||||
dialogue w = 0.810
|
||||
dialogue x = 0.095
|
||||
dialogue y = 0.095
|
||||
|
|
|
@ -150,10 +150,10 @@ namespace GUI
|
|||
MyGUI::IntSize size = button->getTextSize();
|
||||
button->setSize(size.width + 24, button->getSize().height);
|
||||
}
|
||||
MyGUI::Widget* mMainWidget;
|
||||
|
||||
protected:
|
||||
|
||||
MyGUI::Widget* mMainWidget;
|
||||
std::string mPrefix;
|
||||
std::string mLayoutName;
|
||||
MyGUI::VectorWidgetPtr mListWindowRoot;
|
||||
|
|
Loading…
Reference in a new issue