[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit Makefile.am,1.42,1.
From: |
Kai Sterker <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit Makefile.am,1.42,1.43 dlg_circle_entry.cc,1.2,1.3 dlg_compiler.cc,1.2,1.3 gui_dlgedit.cc,1.2,1.3 gui_dlgedit.h,1.2,1.3 main.cc,1.53,1.54 |
Date: |
Tue, 09 Apr 2002 09:15:40 -0400 |
Update of /cvsroot/adonthell/adonthell/src/tools/dlgedit
In directory subversions:/tmp/cvs-serv25775
Modified Files:
Makefile.am dlg_circle_entry.cc dlg_compiler.cc gui_dlgedit.cc
gui_dlgedit.h main.cc
Log Message:
ADDED a couple of command line options to dlgedit
Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/Makefile.am,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** Makefile.am 7 Apr 2002 09:51:28 -0000 1.42
--- Makefile.am 9 Apr 2002 13:15:37 -0000 1.43
***************
*** 13,16 ****
--- 13,17 ----
dlg_circle.cc \
dlg_circle_entry.cc \
+ dlg_cmdline.cc \
dlg_compiler.cc \
dlg_module.cc \
***************
*** 41,44 ****
--- 42,46 ----
dlg_circle.h \
dlg_circle_entry.h \
+ dlg_cmdline.h \
dlg_compiler.h \
dlg_module.h \
Index: dlg_circle_entry.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_circle_entry.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dlg_circle_entry.cc 7 Apr 2002 09:51:28 -0000 1.2
--- dlg_circle_entry.cc 9 Apr 2002 13:15:37 -0000 1.3
***************
*** 42,50 ****
std::string DlgCircleEntry::text ()
{
- // usually, we just need to return the text
- if (GuiDlgedit::window->mode () != L10N_PREVIEW) return text_;
-
// in case we are in preview mode, we need to translate the text first
! return gettext (text_.c_str ());
}
--- 42,51 ----
std::string DlgCircleEntry::text ()
{
// in case we are in preview mode, we need to translate the text first
! if (GuiDlgedit::window && GuiDlgedit::window->mode () == L10N_PREVIEW)
! return gettext (text_.c_str ());
!
! // usually, we just need to return the text
! return text_;
}
Index: dlg_compiler.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_compiler.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dlg_compiler.cc 7 Apr 2002 09:51:28 -0000 1.2
--- dlg_compiler.cc 9 Apr 2002 13:15:37 -0000 1.3
***************
*** 22,25 ****
--- 22,26 ----
#include <iterator>
#include <ostream.h>
+ #include "dlg_cmdline.h"
#include "dlg_compiler.h"
#include "dlg_types.h"
***************
*** 66,74 ****
void DlgCompiler::run ()
{
! // make sure the error console exists
! if (GuiError::console == NULL)
! GuiError::console = new GuiError ();
! else
! GuiError::console->clear ();
// try to open the file
--- 67,78 ----
void DlgCompiler::run ()
{
! if (DlgCmdline::compile == false)
! {
! // make sure the error console exists
! if (GuiError::console == NULL)
! GuiError::console = new GuiError ();
! else
! GuiError::console->clear ();
! }
// try to open the file
***************
*** 105,109 ****
// display errors if there were any
! if (errors > 0)
GuiError::console->display ();
}
--- 109,113 ----
// display errors if there were any
! if (DlgCmdline::compile == false && errors > 0)
GuiError::console->display ();
}
***************
*** 559,564 ****
// add error to list
! GuiError::console->add (error, circle);
!
errors++;
return false;
--- 563,569 ----
// add error to list
! if (DlgCmdline::compile) cout << error;
! else GuiError::console->add (error, circle);
!
errors++;
return false;
***************
*** 577,581 ****
// add error to list
! GuiError::console->add (error, circle);
errors++;
--- 582,587 ----
// add error to list
! if (DlgCmdline::compile) cout << error;
! else GuiError::console->add (error, circle);
errors++;
***************
*** 638,642 ****
// add error to the error console
! GuiError::console->add (error, circle);
errors++;
--- 644,649 ----
// add error to the error console
! if (DlgCmdline::compile) cout << error;
! else GuiError::console->add (error, circle);
errors++;
***************
*** 680,684 ****
error += "\"\n ";
! GuiError::console->add (error, child);
errors++;
--- 687,692 ----
error += "\"\n ";
! if (DlgCmdline::compile) cout << error;
! else GuiError::console->add (error, child);
errors++;
Index: gui_dlgedit.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** gui_dlgedit.cc 7 Apr 2002 09:51:28 -0000 1.2
--- gui_dlgedit.cc 9 Apr 2002 13:15:37 -0000 1.3
***************
*** 365,386 ****
void GuiDlgedit::loadDialogue (std::string file)
{
! // first, open the file
! loadlgin = fopen (file.c_str (), "rb");
!
! if (!loadlgin)
! {
message->display (-2, g_basename (file.c_str ()));
return;
}
- // check if it's a regular file
- struct stat statbuf;
- fstat (fileno (loadlgin), &statbuf);
- if (!S_ISREG (statbuf.st_mode))
- {
- message->display (-2, file.c_str ());
- return;
- }
-
// get the name to use for the dialogue
file += g_strdup_printf ("-%i", ++number);
--- 365,375 ----
void GuiDlgedit::loadDialogue (std::string file)
{
! // test if we have a valid dialogue
! if (!checkDialogue (file))
! {
message->display (-2, g_basename (file.c_str ()));
return;
}
// get the name to use for the dialogue
file += g_strdup_printf ("-%i", ++number);
***************
*** 636,639 ****
--- 625,645 ----
// clear the statusbar
message->clear ();
+ }
+
+ bool GuiDlgedit::checkDialogue (std::string file)
+ {
+ // first, open the file
+ loadlgin = fopen (file.c_str (), "rb");
+
+ if (!loadlgin)
+ return false;
+
+ // check if it's a regular file
+ struct stat statbuf;
+ fstat (fileno (loadlgin), &statbuf);
+ if (!S_ISREG (statbuf.st_mode))
+ return false;
+
+ return true;
}
Index: gui_dlgedit.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** gui_dlgedit.h 7 Apr 2002 09:51:28 -0000 1.2
--- gui_dlgedit.h 9 Apr 2002 13:15:37 -0000 1.3
***************
*** 139,142 ****
--- 139,148 ----
void compileDialogue ();
/**
+ * Test whether the given filename points to a valid dialogue
+ * @param file path of the dialogue
+ * @return <b>true</b> if the dialogue is valid, <b>false</b> otherwise.
+ */
+ static bool checkDialogue (std::string file);
+ /**
* Edit the custom code of the current module.
*/
Index: main.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/main.cc,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -r1.53 -r1.54
*** main.cc 7 Apr 2002 09:51:28 -0000 1.53
--- main.cc 9 Apr 2002 13:15:37 -0000 1.54
***************
*** 29,53 ****
#include "gettext.h"
#include "game.h"
#include "gui_dlgedit.h"
! /*
! int parse_arguments (int argc, char *argv[])
! {
! int c;
!
! while ((c = getopt (argc, argv, "c:")) != -1)
! {
! switch (c)
! {
! case 'c':
! {
!
! break;
! }
! }
! }
!
! return optind;
! }
! */
int main (int argc, char *argv[])
{
--- 29,36 ----
#include "gettext.h"
#include "game.h"
+ #include "dlg_cmdline.h"
+ #include "dlg_compiler.h"
#include "gui_dlgedit.h"
!
int main (int argc, char *argv[])
{
***************
*** 55,337 ****
gtk_init (&argc, &argv);
// Init i18n
setlocale (LC_ALL, "");
// init game directory
! game::init (DATA_DIR"/games");
!
! // Create the User Interface
! GuiDlgedit dlgedit;
!
! // Create a new dialogue
! dlgedit.newDialogue ();
!
! // Start the main loop
! gtk_main ();
!
! // good bye
! return 0;
! }
!
! /*
! class dialog;
!
! extern "C"
! {
! void initcharacterc(void);
! void initquestc(void);
! }
!
! #include <zlib.h>
! #include <unistd.h>
! #include <gtk/gtk.h>
!
! #include "../../types.h"
! #include "../../python_class.h"
! #include "../../prefs.h"
! #include "../../quest.h"
! #include "../../fileops.h"
! #include "main.h"
! #include "graph.h"
! #include "interface.h"
!
!
! int main (int argc, char *argv[])
! {
! char tmp[256];
! PyObject *pyref;
! // The Application Data
! MainFrame *MainWnd = new MainFrame;
!
! // try to read adonthellrc to get path to script directory
! config myconf;
! if (!myconf.read_adonthellrc ())
! return 1;
!
! // we need some data files from a game, so make sure we get them
! myconf.parse_arguments (argc, argv);
!
! // Init GTK+
! gtk_init (&argc, &argv);
!
! // Init Python interpreter
! Py_Initialize ();
!
! // Init the python modules
! initcharacterc ();
! initquestc ();
!
! // Shared modules path
! python::insert_path (DATA_DIR"/modules");
!
! // Path to the dlgedit executable
! char *path = g_dirname (argv[0]);
! if (path[0] != '/')
{
! sprintf (tmp, "%s/%s", getcwd (NULL, 255-strlen (path)), path);
! python::insert_path (tmp);
! }
! else python::insert_path (path);
! free (path);
!
! // Insert our script directory to python's search path
! sprintf (tmp, "%s/scripts", myconf.gamedir.c_str ());
! python::insert_path (tmp);
!
! // ... and the modules directory as well
! sprintf (tmp, "%s/scripts/modules", myconf.gamedir.c_str ());
! python::insert_path (tmp);
!
! // Load module
! PyObject *m = python::import_module ("ins_dlgedit_modules");
! if (m == NULL) return 1;
! // Create a player
! data::globals = PyModule_GetDict(m);
! MainWnd->myplayer = (character *) new character_base ();
!
! // create character array
! PyObject *chars = PyDict_New ();
! PyDict_SetItemString (data::globals, "characters", chars);
!
! sprintf (tmp, "%s/character.data", myconf.gamedir.c_str ());
!
! // load characters from character.data
! igzstream in (tmp);
! if (in.is_open ())
! {
! char ctemp;
! character_base *mynpc = NULL;
!
! if (!fileops::get_version (in, 3, 3, tmp))
! return 1;
!
! MainWnd->myplayer->character_base::get_state (in);
!
! while (ctemp << in)
{
! mynpc = new character_base;
! mynpc->get_state (in);
!
! // Pass character over to Python interpreter
! pyref = python::pass_instance (mynpc, "character");
! PyDict_SetItemString (chars, (char *) mynpc->get_name().c_str (),
pyref);
! Py_DECREF (pyref);
!
! // Make this character available to the engine
! data::characters[mynpc->get_name ().c_str ()] = (character*)
mynpc;
}
!
! if (mynpc == NULL)
{
! mynpc = new character_base ();
! mynpc->set_name ("Dummy Character");
}
!
! MainWnd->set_npc (mynpc);
!
! in.close ();
}
else
{
! cout << "Failed to read file " << tmp << endl << flush;
! return 1;
! }
!
! // create quest array
! PyObject *quests = PyDict_New ();
! PyDict_SetItemString (data::globals, "quests", quests);
!
! // try to open quest.data
! sprintf (tmp, "%s/quest.data", myconf.gamedir.c_str ());
! in.open (tmp);
!
! if (in.is_open ())
! {
! char ctemp;
! quest *myquest;
! if (!fileops::get_version (in, 1, 1, tmp))
! return 1;
!
! // load quests
! while (ctemp << in)
{
! myquest = new quest;
! myquest->load (in);
!
! // Pass quest over to Python interpreter
! pyref = python::pass_instance (myquest, "quest");
! PyDict_SetItemString (quests, (char *) myquest->name.c_str (),
! pyref);
! Py_DECREF (pyref);
!
! // Make this quest available to the engine
! data::quests[myquest->name.c_str ()] = myquest;
}
-
- in.close ();
}
- else
- {
- cout << "Failed to read file " << tmp << endl << flush;
- return 1;
- }
-
- // Misc initialization
- init_app (MainWnd);
-
- // Add the player to the character array
- data::the_player = MainWnd->myplayer;
-
- // Make "the_player" available to the interpreter
- pyref = python::pass_instance (MainWnd->myplayer, "character");
- PyDict_SetItemString (data::globals, "the_player", pyref);
- Py_DECREF (pyref);
-
- MainWnd->wnd = NULL;
- MainWnd->text_dlg = NULL;
- MainWnd->pixmap = NULL;
- MainWnd->dbg_dlg = NULL;
- MainWnd->test_dlg = NULL;
- MainWnd->debug = 0;
-
- // Create Top Level Window and Controls
- create_mainframe (MainWnd);
-
- // Event - Loop
- gtk_main ();
-
- // Clean up
- Py_Finalize ();
-
- delete_dialogue (MainWnd);
- delete MainWnd;
-
- return 0;
- }
-
- void MainFrame::set_changed ()
- {
- if (changed) return;
-
- char *title = GTK_WINDOW (wnd)->title;
- gtk_window_set_title (GTK_WINDOW (wnd), g_strjoin (NULL, title, "
(changed)", NULL));
- changed = 1;
- }
-
- // set a shortcut to one of the NPC's
- void MainFrame::set_npc (character_base *npc)
- {
- mynpc = (character *) npc;
-
- PyObject *charref = python::pass_instance (mynpc, "character");
- PyDict_SetItemString (data::globals, "the_npc", charref);
- Py_DECREF (charref);
- }
-
- // Set variables to safe values
- void
- init_app (MainFrame * MainWnd)
- {
- MainWnd->mode = IDLE;
- MainWnd->number = 0;
- MainWnd->below_pointer = NULL;
- MainWnd->selected_node = NULL;
- MainWnd->dragged_node = NULL;
- MainWnd->tooltip = NULL;
- MainWnd->file_name = g_strdup ("./new_dlg");
- MainWnd->x_offset = 0;
- MainWnd->y_offset = 0;
- MainWnd->scroll = 0;
- MainWnd->scroll_x = 0;
- MainWnd->scroll_y = 0;
- MainWnd->pset_vars = "";
- MainWnd->cust_func = "";
- MainWnd->changed = 0;
! MainWnd->myplayer->set_name ("Banec");
! MainWnd->myplayer->set_val ("race", 0); // Dwarf
! MainWnd->myplayer->set_val ("gender", 1); // Male
!
! data::characters.erase (MainWnd->myplayer->get_name().c_str ());
! data::characters[MainWnd->myplayer->get_name().c_str ()] =
MainWnd->myplayer;
! }
!
! // free allocated memory
! void
! delete_dialogue (MainFrame * wnd)
! {
! u_int32 i;
!
! // Delete all nodes
! for (i = 0; i < wnd->number; i++)
! delete wnd->nodes[i];
!
! wnd->nodes.clear ();
!
! g_free (wnd->file_name);
! if (wnd->tooltip) gtk_widget_destroy (wnd->tooltip);
}
- */
--- 38,114 ----
gtk_init (&argc, &argv);
+ // parse command line
+ if (!DlgCmdline::parse (argc, argv))
+ return 1;
+
// Init i18n
setlocale (LC_ALL, "");
// init game directory
! game::init (DlgCmdline::datadir);
! // start in gui mode
! if (!DlgCmdline::compile)
{
! // Create the User Interface
! GuiDlgedit dlgedit;
! // are there any sources given?
! if (DlgCmdline::sources >= argc)
{
! // Nope -> create a new dialogue
! dlgedit.newDialogue ();
}
! else
{
! // Yep -> load all of them
! while (DlgCmdline::sources < argc)
! dlgedit.loadDialogue (argv[DlgCmdline::sources++]);
}
!
! // Start the main loop
! gtk_main ();
}
+
+ // just compile what we're given and exit
else
{
! DlgModule *module;
! std::string dialogue;
! while (DlgCmdline::sources < argc)
{
! dialogue = argv[DlgCmdline::sources++];
!
! // check whether the file is a valid dialoge
! if (!GuiDlgedit::checkDialogue (dialogue))
! {
! cout << "Loading of '" << dialogue << "' failed\n";
! continue;
! }
!
! module = new DlgModule (dialogue, "");
!
! // try to load from file
! if (!module->load ())
! {
! cout << "Loading of '" << dialogue << "' failed\n";
! }
! else
! {
! cout << "Compiling '" << dialogue << "' ...\n";
!
! // try to compile the dialogue
! DlgCompiler compiler (module);
!
! // compile
! compiler.run ();
! }
!
! delete module;
}
}
! // good bye
! return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/tools/dlgedit Makefile.am,1.42,1.43 dlg_circle_entry.cc,1.2,1.3 dlg_compiler.cc,1.2,1.3 gui_dlgedit.cc,1.2,1.3 gui_dlgedit.h,1.2,1.3 main.cc,1.53,1.54,
Kai Sterker <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/src map_placeable_area.h,1.1.2.5,1.1.2.6 map_moving.h,1.1.2.7,1.1.2.8 map_moving.cc,1.1.2.13,1.1.2.14 map_character_with_gfx.cc,1.1.2.10,1.1.2.11 main.cc,1.39.2.22,1.39.2.23 landmap.h,1.24.4.11,1.24.4.12 landmap.cc,1.18.2.12,1.18.2.13
- Next by Date:
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit dlg_cmdline.cc,NONE,1.1 dlg_cmdline.h,NONE,1.1
- Previous by thread:
[Adonthell-commits] CVS: adonthell/src map_placeable_area.h,1.1.2.5,1.1.2.6 map_moving.h,1.1.2.7,1.1.2.8 map_moving.cc,1.1.2.13,1.1.2.14 map_character_with_gfx.cc,1.1.2.10,1.1.2.11 main.cc,1.39.2.22,1.39.2.23 landmap.h,1.24.4.11,1.24.4.12 landmap.cc,1.18.2.12,1.18.2.13
- Next by thread:
[Adonthell-commits] CVS: adonthell/src/tools/dlgedit dlg_cmdline.cc,NONE,1.1 dlg_cmdline.h,NONE,1.1
- Index(es):