123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /* GCSx
- ** ANIMGROUPPROP.CPP
- **
- ** Animation group 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
- AnimGroupPropertiesDialog* AnimGroupPropertiesDialog::dialog = NULL;
- AnimGroupPropertiesDialog* AnimGroupPropertiesDialog::create() { start_func
- if (!dialog) {
- dialog = new AnimGroupPropertiesDialog();
- }
- return dialog;
- }
- void AnimGroupPropertiesDialog::destroy() { start_func
- if (dialog) {
- delete dialog;
- dialog = NULL;
- }
- }
- AnimGroupPropertiesDialog::AnimGroupPropertiesDialog() : Dialog("Animation Group Properties") { start_func
- initialized = 0;
- }
- Dialog::ButtonAction AnimGroupPropertiesDialog::verifyEntry(int buttonId, Dialog::ButtonAction buttonType) { start_func
- if ((buttonType != BUTTON_APPLY) && (buttonType != BUTTON_OK)) return BUTTON_DEFAULT;
- // Another animation group with same name?
- string lName = dynamic_cast<WTextBox*>(findWidget(ID_NAME))->state();
- toLower(lName);
- const AnimGroup* found = animgroup->getWorld()->findAnimGroup(lName);
- if ((found) && (found != animgroup)) {
- guiErrorBox("A animation group by that name already exists- please choose another.", errorTitleDuplicateName);
- return BUTTON_NOTHING;
- }
-
- if (lName.empty()) {
- guiErrorBox("Please enter a name for this animation group.", errorTitleMissingName);
- return BUTTON_NOTHING;
- }
- return Dialog::verifyEntry(buttonId, buttonType);
- }
- int AnimGroupPropertiesDialog::run(string* title, const AnimGroup* whichAnimGroup) { start_func
- animgroup = whichAnimGroup;
-
- 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;
- }
|