Navigation Menu

Skip to content

Commit

Permalink
ADDED basic questedit application template; only GUI no logic yet
Browse files Browse the repository at this point in the history
  • Loading branch information
ksterker committed Oct 5, 2009
1 parent a554e2e commit 804808d
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/questedit/Makefile.am
@@ -1 +1,25 @@
## Process this file with automake to produce Makefile.in

EXTRA_DIST = questedit.glade

noinst_PROGRAMS = questedit

noinst_HEADERS = \
gui_questedit.h \
qed_cmdline.h

questedit_SOURCES = \
gui_questedit.cc \
main.cc \
qed_cmdline.cc

# just for the dependency
gui_questedit.cc : questedit.glade.h

# generate a string out of the glade XML
$(srcdir)/questedit.glade.h : questedit.glade
sed -e 's/"/\\"/g' -e 's/>$$/>"/' -e 's/^\( *\)</\1"</' $< > $@

INCLUDES = -I@top_srcdir@/src/common -I@top_srcdir@/src
questedit_CXXFLAGS = -D_VERSION_=\"0.1\" $(GTK_CFLAGS) $(PY_CFLAGS) $(ADONTHELL_CFLAGS) ${IGE_MAC_CFLAGS}
questedit_LDADD = ../common/libcommon.a $(GTK_LIBS) $(ADONTHELL_LIBS) ${IGE_MAC_LIBS}
95 changes: 95 additions & 0 deletions src/questedit/gui_questedit.cc
@@ -0,0 +1,95 @@
/*
Copyright (C) 2009 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell 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.
Adonthell 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 Adonthell; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/**
* @file questedit/gui_questedit.cc
*
* @author Kai Sterker
* @brief The quest editor main window.
*/

#include <gtk/gtk.h>

#ifdef MAC_INTEGRATION
#include <ige-mac-integration.h>
#endif

#include "gui_questedit.h"

// Ui definition
static char questedit_ui[] =
#include "questedit.glade.h"
;

// Main Window: on_widget_destroy App
static void on_widget_destroy (GtkWidget * widget, gpointer data)
{
gtk_main_quit ();
gtk_widget_destroy (widget);
}

// ctor
GuiQuestedit::GuiQuestedit ()
{
GError *err = NULL;
GObject *widget;

Ui = gtk_builder_new();
if (!gtk_builder_add_from_string(Ui, questedit_ui, -1, &err))
{
g_message ("building questedit main window failed: %s", err->message);
g_error_free (err);
return;
}

// get reference to dialog window
Window = GTK_WIDGET (gtk_builder_get_object (Ui, "main_window"));
g_signal_connect (Window, "delete-event", G_CALLBACK (on_widget_destroy), (gpointer) NULL);
gtk_widget_show_all (Window);

#ifdef MAC_INTEGRATION
GtkWidget* menu = GTK_WIDGET (gtk_builder_get_object (Ui, "menu_bar"));
GtkWidget* separator = GTK_WIDGET (gtk_builder_get_object (Ui, "item_quit_separator"));
GtkWidget* quit_item = GTK_WIDGET (gtk_builder_get_object (Ui, "item_quit"));

// Mac OSX-Style menu
gtk_widget_hide (separator);
gtk_widget_hide (menu);

ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menu));
ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (quit_item));

// IgeMacMenuGroup *group = ige_mac_menu_add_app_menu_group ();
// ige_mac_menu_add_app_menu_item (group, GTK_MENU_ITEM (quit_item), NULL);
#endif

/*
// connect menu signals
widget = gtk_builder_get_object (Ui, "item_new");
g_signal_connect (widget, "activate", G_CALLBACK (on_file_new), (gpointer) this);
widget = gtk_builder_get_object (Ui, "item_load");
g_signal_connect (widget, "activate", G_CALLBACK (on_file_load), (gpointer) this);
widget = gtk_builder_get_object (Ui, "item_save");
g_signal_connect (widget, "activate", G_CALLBACK (on_file_save_activate), (gpointer) this);
widget = gtk_builder_get_object (Ui, "item_save_as");
g_signal_connect (widget, "activate", G_CALLBACK (on_file_save_as_activate), (gpointer) this);
widget = gtk_builder_get_object (Ui, "item_quit");
g_signal_connect (widget, "activate", G_CALLBACK (on_widget_destroy), (gpointer) NULL);
*/
}
55 changes: 55 additions & 0 deletions src/questedit/gui_questedit.h
@@ -0,0 +1,55 @@
/*
Copyright (C) 2009 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell 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.
Adonthell 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 Adonthell; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/**
* @file questedit/gui_questedit.h
*
* @author Kai Sterker
* @brief The modeller main window.
*/


#ifndef GUI_QUESTEDIT_H
#define GUI_QUESTEDIT_H

/**
* The application main window.
*/
class GuiQuestedit
{
public:
/**
* Create new instance of the GUI
*/
GuiQuestedit();

/**
* Get the application main window.
* @return the main window.
*/
GtkWidget *getWindow () const { return Window; }

private:
/// the main window
GtkWidget *Window;
/// the user interface
GtkBuilder *Ui;
};

#endif
71 changes: 71 additions & 0 deletions src/questedit/main.cc
@@ -0,0 +1,71 @@
/*
Copyright (C) 2009 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell 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.
Adonthell 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 Adonthell; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/**
* @file questedit/main.cc
*
* @author Kai Sterker
* @brief The main function of modeller.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>
#include <base/base.h>
#include <gfx/gfx.h>

#include "qed_cmdline.h"
#include "gui_questedit.h"

#define main main

int main (int argc, char *argv[])
{
// Init GTK+
gtk_init (&argc, &argv);

// parse command line
if (!QedCmdline::parse (argc, argv))
return 1;

// init game directory
base::init (QedCmdline::project, QedCmdline::datadir);

// create the User Interface
GuiQuestedit questedit;

// are there any sources given?
if (QedCmdline::sources >= argc)
{
// Nope -> a new quest tree is created
}
else
{
// Yep -> load quest data
// questedit.loadData (argv[QedCmdline::sources]);
}

// start the main loop
gtk_main ();

// good bye
return 0;
}
113 changes: 113 additions & 0 deletions src/questedit/qed_cmdline.cc
@@ -0,0 +1,113 @@
/*
Copyright (C) 2009 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell 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.
Adonthell 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 Adonthell; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/**
* @file questedit/qed_cmdline.cc
*
* @author Kai Sterker
* @brief Methods to parse the questedit command line.
*/

#include <iostream>
#include <dirent.h>
#include <unistd.h>
#include "qed_cmdline.h"

// the directory to look for project files
std::string QedCmdline::datadir = DATA_DIR"/games";

// the default project
std::string QedCmdline::project = "";

// index of the first dialgoue source in argv[]
int QedCmdline::sources;

// examine the parameters passed to dlgedit
bool QedCmdline::parse (int argc, char* argv[])
{
int c;

// Check for options
while ((c = getopt (argc, argv, "dhvg:p:")) != -1)
{
switch (c)
{
case 'd':
{
std::cout << datadir << std::endl;
return false;
}

case 'v':
{
std::cout << _VERSION_ << std::endl;
return false;
}

case 'p':
{
project = optarg;
break;
}

case 'g':
{
datadir = optarg;

if (datadir[datadir.size () - 1] == '/')
datadir.erase (datadir.size () - 1);

// Check whether the requested game directory exists
DIR * mydir = opendir (datadir.c_str ());

if (!mydir)
{
std::cerr << "No such directory " << datadir << "!" << std::endl;
return false;
}
closedir (mydir);

break;
}

case '?':
case 'h':
{
help (argv[0]);
return false;
}
}
}

sources = optind;
return true;
}

// prints the help message
void QedCmdline::help (const std::string &program)
{
std::cout << "Usage: " << program << " [OPTIONS] [QUEST DATA]" << std::endl;
std::cout << std::endl;
std::cout << "Where [OPTIONS] can be:\n";
std::cout << "-h print this help message and exit" << std::endl;
std::cout << "-d print the project directory and exit" << std::endl;
std::cout << "-v print version and exit" << std::endl;
std::cout << "-g dir specify a custom project directory" << std::endl;
std::cout << "-p project specify a default project" << std::endl;
}

0 comments on commit 804808d

Please sign in to comment.