Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Saving settings to registry is functional.
  • Loading branch information
codereader committed Nov 8, 2017
1 parent e566853 commit 6cb6787
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions radiant/ui/prefdialog/GameSetupDialog.cpp
Expand Up @@ -5,6 +5,7 @@
#include "igame.h"
#include "modulesystem/ModuleRegistry.h"

#include "registry/registry.h"
#include "GameSetupPageIdTech.h"
#include <wx/panel.h>
#include <wx/sizer.h>
Expand Down Expand Up @@ -64,6 +65,10 @@ void GameSetupDialog::initialiseControls()

// For each game type create a separate page in the choice book
GameSetupPage* page = GameSetupPage::CreatePageForType(type, container);
page->SetName("GameSetupPage");

// Store the game value as client data into the page object
page->SetClientData(new wxStringClientData(game->getKeyValue("name")));

container->GetSizer()->Add(page, 1, wxEXPAND | wxALL, 12);

Expand All @@ -73,8 +78,23 @@ void GameSetupDialog::initialiseControls()

void GameSetupDialog::save()
{
// Save paths to the registry
// TODO
if (_book->GetSelection() == wxNOT_FOUND)
{
rError() << "Cannot save game type, nothing selected" << std::endl;
return;
}

// Extract the game type value from the current page and save it to the registry
wxWindow* container = _book->GetPage(_book->GetSelection());
GameSetupPage* page = dynamic_cast<GameSetupPage*>(wxWindow::FindWindowByName("GameSetupPage", container));

wxStringClientData* data = static_cast<wxStringClientData*>(page->GetClientData());

std::string selectedGame = data->GetData().ToStdString();
registry::setValue(RKEY_GAME_TYPE, selectedGame);

// Ask the current page to set the paths to the registry
page->saveSettings();
}

void GameSetupDialog::Show(const cmd::ArgumentList& args)
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/prefdialog/GameSetupPageIdTech.cpp
Expand Up @@ -47,7 +47,7 @@ void GameSetupPageIdTech::validateSettings()

void GameSetupPageIdTech::saveSettings()
{

_registryBuffer.commitChanges();
}

wxWindow* GameSetupPageIdTech::createEntry(const std::string& registryKey)
Expand Down

0 comments on commit 6cb6787

Please sign in to comment.