Planeshift
|
00001 /* 00002 * Author: Andrew Robberts 00003 * 00004 * Copyright (C) 2007 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * http://www.atomicblue.org) 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef PAWS_SCRIPT_H 00021 #define PAWS_SCRIPT_H 00022 00023 #include <csutil/array.h> 00024 #include "util/mathscript.h" 00025 00026 class pawsWidget; 00027 00032 struct pawsScriptResult 00033 { 00034 pawsWidget* widget; 00035 MathVar* var; 00036 csString property; 00037 }; 00038 00039 class pawsScriptStatement 00040 { 00041 private: 00042 MathScript* script; 00043 MathEnvironment env; 00044 csArray<pawsScriptResult> scriptResults; 00045 00046 static void ChangedResultsVarCallback(void* arg); 00047 public: 00048 pawsScriptStatement(const char* script); 00049 virtual ~pawsScriptStatement(); 00050 00051 void AddLHSResult(pawsWidget* widget, const char* property, const char* name); 00052 void AddRHSVar(iScriptableVar* v, const char* name); 00053 00054 void Execute(); 00055 }; 00056 00057 class pawsScript 00058 { 00059 private: 00060 pawsScriptStatement* statement; 00061 pawsWidget* widget; 00062 csString scriptText; 00063 00064 bool NextChar(const char* script, size_t &currIndex, char &c, char &n); 00065 bool Parse(const char* script); 00066 00067 pawsWidget* FindWidget(pawsWidget* widget, const char* name); 00068 public: 00069 pawsScript(pawsWidget* widget, const char* script); 00070 ~pawsScript(); 00071 00072 void Execute(); 00073 }; 00074 00077 #endif // PAWS_SCRIPT_H