gcsx_sceneprop.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* GCSx
  2. ** SCENEPROP.CPP
  3. **
  4. ** Scene properties dialog
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #include "all.h"
  24. // Properties dialog
  25. ScenePropertiesDialog* ScenePropertiesDialog::dialog = NULL;
  26. ScenePropertiesDialog* ScenePropertiesDialog::create() { start_func
  27. if (!dialog) {
  28. dialog = new ScenePropertiesDialog();
  29. }
  30. return dialog;
  31. }
  32. void ScenePropertiesDialog::destroy() { start_func
  33. if (dialog) {
  34. delete dialog;
  35. dialog = NULL;
  36. }
  37. }
  38. ScenePropertiesDialog::ScenePropertiesDialog() : Dialog("Scene Properties") { start_func
  39. initialized = 0;
  40. }
  41. Dialog::ButtonAction ScenePropertiesDialog::verifyEntry(int buttonId, Dialog::ButtonAction buttonType) { start_func
  42. if ((buttonType != BUTTON_APPLY) && (buttonType != BUTTON_OK)) return BUTTON_DEFAULT;
  43. // Another scene with same name?
  44. string lName = dynamic_cast<WTextBox*>(findWidget(ID_NAME))->state();
  45. toLower(lName);
  46. const Scene* found = scene->getWorld()->findScene(lName);
  47. if ((found) && (found != scene)) {
  48. guiErrorBox("A scene by that name already exists- please choose another.", errorTitleDuplicateName);
  49. return BUTTON_NOTHING;
  50. }
  51. if (lName.empty()) {
  52. guiErrorBox("Please enter a name for this scene.", errorTitleMissingName);
  53. return BUTTON_NOTHING;
  54. }
  55. return Dialog::verifyEntry(buttonId, buttonType);
  56. }
  57. int ScenePropertiesDialog::run(string* title, const Scene* whichScene) { start_func
  58. scene = whichScene;
  59. if (!initialized) {
  60. Widget* w = NULL;
  61. w = new WStatic(ID_LABEL, "\tName:");
  62. w->addTo(this);
  63. w = new WTextBox(ID_NAME, title, 0);
  64. w->addTo(this);
  65. w = new WButton(ID_OK, messageBoxOK, BUTTON_OK);
  66. w->addTo(this);
  67. w = new WButton(ID_CANCEL, messageBoxCancel, BUTTON_CANCEL);
  68. w->addTo(this);
  69. makePretty();
  70. initialized = 1;
  71. }
  72. else {
  73. findWidget(ID_NAME)->changeStorage(title);
  74. }
  75. // Hit OK?
  76. if (runModal() == ID_OK) return 1;
  77. return 0;
  78. }