123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /* GCSx
- ** SCENEPROP.CPP
- **
- ** Scene properties dialog
- */
- /*****************************************************************************
- ** Copyright (C) 2003-2006 Janson
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
- *****************************************************************************/
- #include "all.h"
- // Properties dialog
- ScenePropertiesDialog* ScenePropertiesDialog::dialog = NULL;
- ScenePropertiesDialog* ScenePropertiesDialog::create() { start_func
- if (!dialog) {
- dialog = new ScenePropertiesDialog();
- }
- return dialog;
- }
- void ScenePropertiesDialog::destroy() { start_func
- if (dialog) {
- delete dialog;
- dialog = NULL;
- }
- }
- ScenePropertiesDialog::ScenePropertiesDialog() : Dialog("Scene Properties") { start_func
- initialized = 0;
- }
- Dialog::ButtonAction ScenePropertiesDialog::verifyEntry(int buttonId, Dialog::ButtonAction buttonType) { start_func
- if ((buttonType != BUTTON_APPLY) && (buttonType != BUTTON_OK)) return BUTTON_DEFAULT;
- // Another scene with same name?
- string lName = dynamic_cast<WTextBox*>(findWidget(ID_NAME))->state();
- toLower(lName);
- const Scene* found = scene->getWorld()->findScene(lName);
- if ((found) && (found != scene)) {
- guiErrorBox("A scene by that name already exists- please choose another.", errorTitleDuplicateName);
- return BUTTON_NOTHING;
- }
-
- if (lName.empty()) {
- guiErrorBox("Please enter a name for this scene.", errorTitleMissingName);
- return BUTTON_NOTHING;
- }
- return Dialog::verifyEntry(buttonId, buttonType);
- }
- int ScenePropertiesDialog::run(string* title, const Scene* whichScene) { start_func
- scene = whichScene;
-
- if (!initialized) {
- Widget* w = NULL;
-
- w = new WStatic(ID_LABEL, "\tName:");
- w->addTo(this);
- w = new WTextBox(ID_NAME, title, 0);
- w->addTo(this);
- w = new WButton(ID_OK, messageBoxOK, BUTTON_OK);
- w->addTo(this);
-
- w = new WButton(ID_CANCEL, messageBoxCancel, BUTTON_CANCEL);
- w->addTo(this);
-
- makePretty();
-
- initialized = 1;
- }
- else {
- findWidget(ID_NAME)->changeStorage(title);
- }
-
- // Hit OK?
- if (runModal() == ID_OK) return 1;
- return 0;
- }
|