sludge-2.2/ 0000755 0001750 0001750 00000000000 11704651220 007637 5 0000000 0000000 sludge-2.2/GTK_Dev_Kit/ 0000755 0001750 0001750 00000000000 11704651221 011672 5 0000000 0000000 sludge-2.2/GTK_Dev_Kit/SpriteBankEditor.glade 0000644 0001750 0001750 00000121233 11700301464 016020 0000000 0000000
0.59999999999999998
1
-2000
2000
1
-2000
2000
1
True
gtk-select-font
5
Fontify...
normal
False
True
vertical
2
True
6
12
True
True
●
fontify_adjustment
0
True
Width of space character that will be added to the end of the font.
True
1
False
1
True
end
gtk-cancel
True
True
True
True
False
False
0
gtk-ok
True
True
True
True
False
False
1
False
end
0
button1
button2
1
1
1000
1
10
5
Apply hotspot to range
normal
False
True
vertical
2
True
6
12
True
2
2
12
12
True
True
●
multi_from_adjustment
1
2
True
True
●
multi_to_adjustment
1
2
1
2
True
0
From:
True
0
To:
1
2
False
0
True
This will copy the hotspot coordinates from the current frame to the selected range of frames.
True
1
False
1
True
end
gtk-cancel
True
True
True
True
False
False
0
gtk-ok
True
True
True
True
False
False
1
False
end
0
button3
button4
100
1
10
100
1
10
sludge-2.2/GTK_Dev_Kit/TranslationEditor.glade 0000644 0001750 0001750 00000034074 11700301464 016262 0000000 0000000
SLUDGE Translation Editor
600
580
True
vertical
False
0
True
12
vertical
12
True
6
Load strings from project
True
True
True
False
0
True
0
ID:
False
1
True
True
●
id_adjustment
False
2
True
1
Language name:
False
3
True
True
●
4
False
0
True
True
automatic
automatic
in
True
True
1
True
6
True
False
0
True
1
Find:
False
1
True
True
●
2
False
2
True
queue
True
True
6
6
2
False
word-char
6
6
original_textbuffer
False
3
True
queue
True
True
6
6
2
False
word-char
6
6
translation_textbuffer
False
4
1
1
1
100
1
1
sludge-2.2/GTK_Dev_Kit/SludgeZBufferMaker.h 0000644 0001750 0001750 00000004274 11700301464 015456 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeZBufferMaker.h - Part of the SLUDGE Z-Buffer Maker (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "SludgeGLApplication.h"
#include "sprites.h"
class SludgeZBufferMaker : public SludgeGLApplication {
private:
struct spriteBank backdrop;
GtkAdjustment *theSliderAdjustment;
GtkAdjustment *theYAdjustment;
GtkLabel *theNumBuffersLabel;
GtkWidget *saveItem, *saveAsItem;
int mouseLoc1x, mouseLoc1y;
private:
// Concrete methods for SludgeApplication:
virtual gboolean init(gboolean calledFromConstructor);
virtual const char * getWindowTitle();
virtual const char * getFilterName();
virtual const char * getFilterPattern();
virtual const char * getUntitledFilename();
virtual gboolean saveFile(char *filename);
virtual gboolean loadFile(char *filename);
virtual void postNew();
virtual void postOpen();
// Concrete methods for SludgeGLApplication:
virtual void button1Press(int local_pointx, int local_pointy);
virtual void button1Release(int local_pointx, int local_pointy);
virtual void button1Motion(int local_pointx, int local_pointy);
virtual void drawingareaLeft();
virtual void prepareOpenGL();
virtual void drawRect();
void setupButtons();
struct spriteBank * getBackdrop();
int bufferY();
void setBufferY(int i);
int buffer();
void setBuffer(int i);
public:
SludgeZBufferMaker();
// Callbacks:
void on_hscale_value_changed(GtkHScale *theScale);
void on_spinbutton_value_changed(GtkSpinButton *theSpinButton);
};
sludge-2.2/GTK_Dev_Kit/TranslationEditorMain.h 0000644 0001750 0001750 00000003216 11700301464 016234 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* TranslationEditorMain.h - Part of the SLUDGE Translation Editor (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#ifdef __cplusplus
extern "C" {
#endif
G_MODULE_EXPORT void
on_tree_selection_changed_cb(GtkTreeSelection *theSelection, gpointer theUser_data);
G_MODULE_EXPORT void
on_translate_toggled_cb(GtkCellRendererToggle *theCell_renderer, gchar *thePath, gpointer theUser_data);
G_MODULE_EXPORT void
on_translation_edited_cb(GtkCellRendererText *theCell_renderer, gchar *thePath, gchar *theNewText, gpointer theUser_data);
G_MODULE_EXPORT void
on_sort_original_clicked_cb(GtkTreeViewColumn *theTreeViewColumn, gpointer theUser_data);
G_MODULE_EXPORT void
on_sort_translation_clicked_cb(GtkTreeViewColumn *theTreeViewColumn, gpointer theUser_data);
G_MODULE_EXPORT gboolean
searchEqualFunc_cb(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data);
#ifdef __cplusplus
}
#endif
sludge-2.2/GTK_Dev_Kit/SludgeApplication.cpp 0000644 0001750 0001750 00000023212 11704132355 015727 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeApplication.cpp - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#ifdef __WIN32
#include
#endif
#include "SludgeApplication.h"
#include "Common.h"
#include "version.h"
SludgeApplication::SludgeApplication(const char * gladeFileName, const char * iconName, const char * configFile)
{
configfile = configFile;
GError *err = NULL;
initSuccess = TRUE;
char buf[1000];
GdkPixbuf *pixbuf16, *pixbuf32, *pixbuf128, *pixbuf256;
GList *list = NULL;
sprintf(buf, "%s%s_16x16x32.png", DATADIR, iconName);
pixbuf16 = gdk_pixbuf_new_from_file (buf, &err);
if (err == NULL) {
sprintf(buf, "%s%s_32x32x32.png", DATADIR, iconName);
pixbuf32 = gdk_pixbuf_new_from_file (buf, &err);
}
if (err == NULL) {
sprintf(buf, "%s%s_128x128x32.png", DATADIR, iconName);
pixbuf128 = gdk_pixbuf_new_from_file (buf, &err);
}
if (err == NULL) {
sprintf(buf, "%s%s_256x256x32.png", DATADIR, iconName);
pixbuf256 = gdk_pixbuf_new_from_file (buf, &err);
}
if (err != NULL)
{
fprintf (stderr, "Unable to open icon file: %s\n", err->message);
g_error_free (err);
} else {
list = g_list_append (list, pixbuf16);
list = g_list_append (list, pixbuf32);
list = g_list_append (list, pixbuf128);
list = g_list_append (list, pixbuf256);
gtk_window_set_default_icon_list(list);
}
/*
* Load the GTK interface.
*/
theXml = gtk_builder_new ();
if (!gtk_builder_add_from_file (theXml, gladeFileName, NULL))
{
g_critical ("Failed to load the GTK file.\n");
errorBox("Error!", joinTwoStrings("Failed to load resource file:\n", gladeFileName));
initSuccess = FALSE;
return;
}
/*
* Get the top-level window reference from loaded Glade file.
*/
theWindow = GTK_WIDGET (gtk_builder_get_object (theXml, "window1"));
if (theWindow == NULL)
{
g_critical ("Failed to get the window from the builder.\n");
initSuccess = FALSE;
return;
}
// Set unassigned widgets to get handled automatically by the window manager.
gtk_container_set_reallocate_redraws (GTK_CONTAINER (theWindow), TRUE);
char folderFile[300];
sprintf(folderFile, "%s/sludge-devkit/%s", g_get_user_config_dir(), configfile);
FILE * fp = fopen (folderFile, "r");
if (fp) {
char readChar = ' ';
for (int i = 0; i < 300; i++) {
readChar = fgetc(fp);
if (readChar != '\n') {
currentFolder[i] = readChar;
} else {
currentFolder[i] = 0;
break;
}
}
fclose (fp);
} else {
sprintf (currentFolder, "%s", g_get_home_dir());
}
fileChanged = FALSE;
currentFilename[0] = 0;
currentShortname[0] = 0;
}
SludgeApplication::~SludgeApplication()
{
if (currentFolder[0] != 0)
{
if (g_chdir(g_get_user_config_dir())) return;
#ifdef __WIN32
_mkdir("sludge-devkit");
#else
g_mkdir("sludge-devkit", 0000777);
#endif
if (g_chdir("sludge-devkit")) return;
FILE * fp = fopen (configfile, "w");
if (fp) {
fprintf (fp, "%s\n", currentFolder);
fclose (fp);
}
}
}
void SludgeApplication::saveToFile()
{
GtkWidget *dialog;
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new ("Save File",
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, getFilterName());
gtk_file_filter_add_pattern(filter, getFilterPattern());
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
if (currentShortname[0] != 0)
{
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), currentShortname);
}
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
flipBackslashes(&filename);
if (!saveFile (filename))
{
errorBox ("Error", "Saving file failed.");
}
else
{
setFilename(filename);
setFolderFromFilename(filename);
}
g_free (filename);
}
gtk_widget_destroy (dialog);
}
gboolean SludgeApplication::reallyClose()
{
if (fileChanged) {
GtkWidget *dialog;
gint response;
dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"Save the changes to '%s' before closing?", currentShortname);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
"Don't Save", GTK_RESPONSE_REJECT,
"Cancel", GTK_RESPONSE_CANCEL,
"Save", GTK_RESPONSE_ACCEPT,
NULL);
gtk_window_set_title(GTK_WINDOW(dialog), "There are unsaved changes.");
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_NONE) {
return FALSE;
}
if (response == GTK_RESPONSE_ACCEPT) {
on_save();
}
}
return TRUE;
}
void SludgeApplication::setFilename(char* filename)
{
int i, lastSlash, j;
lastSlash = -1;
for (i = 0; filename[i] != 0; i++) {
currentFilename[i] = filename[i];
if (filename[i] == '/')
lastSlash = i;
}
currentFilename[i] = 0;
for (j = lastSlash + 1; j <= i; j++) {
currentShortname[j-lastSlash-1] = filename[j];
}
gtk_window_set_title (GTK_WINDOW(theWindow), currentShortname);
fileChanged = FALSE;
}
void SludgeApplication::setFolderFromFilename(char* filename)
{
int i, lastSlash, j;
for (i = 0; filename[i] != 0; i++) {
if (filename[i] == '/')
lastSlash = i;
}
for (j = 0; j < lastSlash; j++) {
currentFolder[j] = filename[j];
}
currentFolder[lastSlash] = 0;
}
void SludgeApplication::setFileChanged()
{
if (!fileChanged) {
if (currentShortname[0] == 0) {
sprintf (currentShortname, "%s", getUntitledFilename());
}
gtk_window_set_title (GTK_WINDOW(theWindow), joinTwoStrings("*", currentShortname));
fileChanged = TRUE;
}
}
void SludgeApplication::open(char* filename)
{
if (!loadFile (filename))
{
errorBox ("Error", "Loading file failed.");
}
else
{
setFilename(filename);
setFolderFromFilename(filename);
postOpen ();
}
}
// Callbacks:
gboolean SludgeApplication::on_window1_delete_event()
{
if (reallyClose()) {
gtk_main_quit ();
return FALSE;
} else {
return TRUE;
}
}
void SludgeApplication::on_new()
{
if (!reallyClose()) return;
init(FALSE);
currentFilename[0] = 0;
sprintf (currentShortname, "%s", getUntitledFilename());
gtk_window_set_title (GTK_WINDOW(theWindow), getWindowTitle());
fileChanged = FALSE;
postNew ();
}
void SludgeApplication::on_open()
{
if (!reallyClose()) return;
GtkWidget *dialog;
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new ("Open File",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, getFilterName());
gtk_file_filter_add_pattern(filter, getFilterPattern());
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
flipBackslashes(&filename);
open(filename);
g_free (filename);
}
gtk_widget_destroy (dialog);
}
void SludgeApplication::on_save()
{
if (currentFilename[0] != 0) {
if (!saveFile (currentFilename))
{
errorBox ("Error", "Saving file failed.");
} else {
gtk_window_set_title (GTK_WINDOW(theWindow), currentShortname);
fileChanged = FALSE;
}
}
else
{
saveToFile();
}
}
void SludgeApplication::on_save_as()
{
saveToFile();
}
void SludgeApplication::on_about()
{
const gchar *authors[] = { "Tim Furnish", "Rikard Peterson", "Tobias Hansen ", NULL };
gtk_show_about_dialog( GTK_WINDOW(theWindow),
"program-name", getWindowTitle(),
"authors", authors,
"copyright", "© 2000-2012 Hungry Software and contributors",
"license",
"This program is free software: you can redistribute it and/or modify\n\
it under the terms of the GNU General Public License as published by\n\
the Free Software Foundation, either version 3 of the License, or\n\
(at your option) any later version.\n\
\n\
This program is distributed in the hope that it will be useful,\n\
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
GNU General Public License for more details.\n\
\n\
You should have received a copy of the GNU General Public License\n\
along with this program. If not, see .",
"version", TEXT_VERSION,
"website", "http://opensludge.sourceforge.net",
"website-label", "Website",
NULL);
}
sludge-2.2/GTK_Dev_Kit/SludgeFloorMaker.cpp 0000644 0001750 0001750 00000021244 11700301464 015523 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeFloorMaker.cpp - Part of the SLUDGE Floor Maker (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include "floormaker.h"
#include "sprites.h"
#include "splitter.hpp"
#include "Common.h"
#include "SludgeFloorMaker.h"
SludgeFloorMaker::SludgeFloorMaker()
: SludgeGLApplication(joinTwoStrings(DATADIR, "FloorMaker.glade"), "floorIcon", "floormaker")
{
if (!initSuccess) return;
init(TRUE);
}
SludgeFloorMaker::~SludgeFloorMaker()
{
if (backdrop.total) {
forgetSpriteBank(&backdrop);
backdrop.total = 0;
noFloor(&firstPoly);
}
}
// Concrete methods for SludgeApplication:
gboolean SludgeFloorMaker::init(gboolean calledFromConstructor)
{
firstPoly = 0;
noFloor(&firstPoly);
backdrop.total=0;
backdrop.type=2;
backdrop.sprites=NULL;
backdrop.myPalette.pal = NULL;
backdrop.myPalette.r=NULL;
backdrop.myPalette.g=NULL;
backdrop.myPalette.b=NULL;
if (!calledFromConstructor) {
prepareOpenGL();
}
if (!reserveSpritePal(&backdrop.myPalette, 0)) {
return TRUE;
}
return FALSE;
}
const char * SludgeFloorMaker::getWindowTitle()
{
return "SLUDGE Floor Maker";
}
const char * SludgeFloorMaker::getFilterName()
{
return "SLUDGE Floor Files (*.flo)";
}
const char * SludgeFloorMaker::getFilterPattern()
{
return "*.[fF][lL][oO]";
}
const char * SludgeFloorMaker::getUntitledFilename()
{
return "Untitled Floor.flo";
}
gboolean SludgeFloorMaker::saveFile(char *filename)
{
return saveFloorToFile(filename, &firstPoly);
}
gboolean SludgeFloorMaker::loadFile(char *filename)
{
return loadFloorFromFile(filename, &firstPoly);
}
void SludgeFloorMaker::postOpen() {}
void SludgeFloorMaker::postNew() {}
// Concrete methods for SludgeGLApplication:
void SludgeFloorMaker::button1Press(int local_pointx, int local_pointy)
{
gboolean keepOn = TRUE;
int i, xx, yy;
mouseLoc1x = local_pointx;
mouseLoc1y = local_pointy;
xx = (local_pointx+x)*zmul;
yy = (local_pointy-y)*zmul;
switch (mode) {
case 0: // Define floor border
snapToClosest(&xx, &yy, getFloor());
while (keepOn) {
keepOn = FALSE;
i = addVertex(xx, yy, getFloor());
switch (i) {
case 1:
setFileChanged();
return;
case 0:
errorBox("Can't add vertex", "Out of memory.");
return;
case 3:
errorBox("Can't add vertex", "That vertex is already used in this polygon, but isn't the start point.");
return;
case 2:
if ( askAQuestion("Can't add vertex", "Can't add another vertex as the floor is already complete... do you want to start a NEW polygon at this point?") ) {
setFloor( addPoly(getFloor()) );
keepOn = TRUE;
setFileChanged();
} else {
return;
}
break;
}
}
break;
case 1: // Move vertices
case 4: // Split lines
case 5: // Split segments
if (! snapToClosest(&xx, &yy, getFloor()))
return;
selx1 = xx;
sely1 = yy;
selection = 1;
awaitButton1Release = TRUE;
break;
case 2: // Remove vertices
if (! snapToClosest(&xx, &yy, getFloor()))
return;
struct polyList * firstPoly = getFloor();
killVertex(xx, yy, &firstPoly);
setFloor(firstPoly);
setFileChanged();
break;
}
lit = snapToClosest(&xx, &yy, getFloor());
litX = xx; litY = yy;
}
void SludgeFloorMaker::button1Release(int local_pointx, int local_pointy)
{
int xx, yy;
awaitButton1Release = FALSE;
selx2 = xx = (local_pointx+x)*zmul;
sely2 = yy = (local_pointy-y)*zmul;
lit = snapToClosest(&xx, &yy, getFloor());
litX = xx;
litY = yy;
if (lit && (xx != selx1 || yy != sely1)) {
selx2 = xx;
sely2 = yy;
}
selection = 0;
switch (mode) {
case 1: // Move vertices
if (moveVertices(selx1, sely1, selx2, sely2, getFloor())) {
setFileChanged();
} else {
errorBox("Can't move vertex", "Sorry - that vertex is already contained in one or more of the polygons you're changing.");
return;
}
break;
case 4: // Split lines
splitLine(selx1, sely1, selx2, sely2, getFloor());
setFileChanged();
break;
case 5: // Split segments
struct polyList * firstPoly = getFloor();
splitPoly(selx1, sely1, selx2, sely2, &firstPoly);
setFloor(firstPoly);
setFileChanged();
break;
}
}
void SludgeFloorMaker::button1Motion(int local_pointx, int local_pointy)
{
int xx, yy;
selx2 = xx = (local_pointx+x)*zmul;
sely2 = yy = (local_pointy-y)*zmul;
lit = snapToClosest(&xx, &yy, getFloor());
litX = xx;
litY = yy;
if (lit && (xx != selx1 || yy != sely1)) {
selx2 = xx;
sely2 = yy;
}
}
void SludgeFloorMaker::drawingareaLeft()
{
selection = 0;
}
void SludgeFloorMaker::prepareOpenGL()
{
if (! backdrop.total)
addSprite(0, &backdrop);
z = 0.0;
r = g = b = 1.0;
zmul = (1.0+z/20);
setCoords();
}
void SludgeFloorMaker::drawRect()
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.00f, 1.00f);
pasteSprite(&backdrop.sprites[0], &backdrop.myPalette, FALSE);
glDisable(GL_TEXTURE_2D);
glColor3f(1.0f, 0.35f, 0.35f);
glBegin(GL_LINES);
{
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 1000.0, 0.0, 0.0);
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 0.0, 1000.0, 0.0);
}
glEnd();
if (lit) {
glColor3f(1.0f, 0.00f, 1.00f);
glBegin(GL_QUADS);
{
glVertex3i( litX-8, litY-8, 0);
glVertex3i( litX+8, litY-8, 0);
glVertex3i( litX+8, litY+8, 0);
glVertex3i( litX-8, litY+8, 0);
}
glEnd();
}
drawFloor(getFloor(), r, g, b);
if (selection == 1) {
glColor3f(1.0f, 0.00f, 1.00f);
glBegin(GL_LINES);
{
glVertex3i(selx1, sely1, 0);
glVertex3i(selx2, sely2, 0);
}
glEnd();
}
}
struct polyList * SludgeFloorMaker::getFloor() {
return firstPoly;
}
void SludgeFloorMaker::setFloor(struct polyList * floor)
{
firstPoly = floor;
}
// Callbacks:
void SludgeFloorMaker::on_filechooserbutton_realize(GtkFileChooser *theChooser)
{
setFileChooserFilters(theChooser, TRUE, TRUE);
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder(theChooser, currentFolder);
}
}
void SludgeFloorMaker::on_filechooserbutton_file_set(GtkFileChooser *theChooser)
{
char *filename;
gboolean success = 0;
filename = gtk_file_chooser_get_filename(theChooser);
if (filename == NULL) return;
flipBackslashes(&filename);
if (strlen(filename) > 4) {
char * extension = filename + strlen(filename) - 4;
if (!strcmp(extension, ".png") || !strcmp(extension, ".PNG")) {
success = loadSpriteFromPNG(filename, &backdrop, 0);
} else if (!strcmp(extension, ".tga") || !strcmp(extension, ".TGA")) {
success = loadSpriteFromTGA(filename, &backdrop, 0);
}
} else {
errorBox("Can't load image", "I don't recognise the file type. TGA and PNG are the supported file types.");
}
if (success) {
setFolderFromFilename(filename);
backdrop.sprites[0].height = -backdrop.sprites[0].height;
activateZoomButtons(backdrop.sprites[0].width, -backdrop.sprites[0].height);
showStatusbar(backdrop.sprites[0].width, -backdrop.sprites[0].height);
on_zoom_fit_clicked();
reshape();
render_timer_event(theDrawingarea);
}
g_free(filename);
}
void SludgeFloorMaker::on_colorbutton_realize(GtkColorButton *theButton)
{
GdkColor theColor;
theColor.red = theColor.blue = theColor.green = 65535;
gtk_color_button_set_color(theButton, &theColor);
}
void SludgeFloorMaker::on_colorbutton_color_set(GtkColorButton *theButton)
{
GdkColor theColor;
gtk_color_button_get_color(theButton, &theColor);
r = theColor.red / 65535.;
g = theColor.green / 65535.;
b = theColor.blue / 65535.;
}
void SludgeFloorMaker::on_mode_changed(int buttonClicked)
{
mode = buttonClicked;
}
sludge-2.2/GTK_Dev_Kit/ProjectManagerMain.h 0000644 0001750 0001750 00000002225 11700301464 015467 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* ProjectManagerMain.h - Part of the SLUDGE Project Manager (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "compilerinfo.h"
#ifdef __cplusplus
extern "C" {
#endif
G_MODULE_EXPORT void
on_files_tree_selection_changed_cb (GtkTreeSelection *theSelection, gpointer theUser_data);
G_MODULE_EXPORT void *compile_hook(gpointer nothing);
void receiveCompilerInfo(compilerInfo *info);
#ifdef __cplusplus
}
#endif
sludge-2.2/GTK_Dev_Kit/Common.h 0000644 0001750 0001750 00000002661 11700301464 013215 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Common.h - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#ifdef __cplusplus
extern "C" {
#endif
const char * getTempDir ();
bool askAQuestion (const char * head, const char * msg);
bool errorBox (const char * head, const char * msg);
#ifdef __cplusplus
}
#endif
void setFileChooserFilters(GtkFileChooser *theFileChooser, gboolean png, gboolean tga);
char * joinTwoStrings (const char * a, const char * b);
bool fileExists(char * file);
void flipBackslashes(char **string);
void winChangeToProgramDir(const char *programFullPath);
void replaceInvalidCharacters(char *string, int *retval);
int sh_cmd (char * path, const char * cmd, char * args);
sludge-2.2/GTK_Dev_Kit/FloorMaker.glade 0000644 0001750 0001750 00000046613 11700301464 014660 0000000 0000000
SLUDGE Floor Maker
680
580
True
vertical
False
0
True
icons
True
200
True
Load backdrop
False
Load Backdrop
False
True
False
True
Show backdrop at its normal size
Show backdrop at its normal size
True
gtk-zoom-100
False
True
Fit backdrop to window
Fit backdrop to window
True
gtk-zoom-fit
False
True
False
True
True
True
True
Choose color for floor outlines
Choose a color
#000000000000
False
True
False
True
True
Mode:
False
True
Define floor borders
Define floor borders
True
image1
False
True
Move vertices
Move vertices
True
image2
define_borders
False
True
Delete vertices
Delete vertices
True
image3
move_vertices
False
True
Split line
Split line
True
image4
delete_vertices
False
True
Split floor
Split floor
True
image5
split_line
False
False
1
True
12
queue
True
2
True
2
0
False
0
,
False
1
0
False
2
False
3
0
False
4
x
False
5
0
False
6
100
False
8
%
False
9
False
3
True
floormodeicon2.png
True
floormodeicon1.png
True
floormodeicon3.png
True
floormodeicon4.png
True
floormodeicon5.png
sludge-2.2/GTK_Dev_Kit/SludgeGLApplication.cpp 0000644 0001750 0001750 00000033625 11700301464 016156 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeGLApplication.cpp - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include "SludgeGLApplication.h"
SludgeGLApplication::SludgeGLApplication(const char * gladeFileName, const char * iconName, const char * configFile)
: SludgeApplication(gladeFileName, iconName, configFile)
{
if (!initSuccess) return;
pixmap = NULL;
glpixmap = NULL;
context = NULL;
glDrawable = NULL;
glContext = NULL;
statusbarWidget = GTK_WIDGET (gtk_builder_get_object (theXml, "statusbar"));
cursorxLabel = GTK_LABEL (gtk_builder_get_object (theXml, "cursorx_label"));
cursoryLabel = GTK_LABEL (gtk_builder_get_object (theXml, "cursory_label"));
picwLabel = GTK_LABEL (gtk_builder_get_object (theXml, "picw_label"));
pichLabel = GTK_LABEL (gtk_builder_get_object (theXml, "pich_label"));
zmulLabel = GTK_LABEL (gtk_builder_get_object (theXml, "zmul_label"));
zoom100Button = NULL;
zoomFitButton = NULL;
awaitButton1Release = FALSE;
awaitButton2Release = FALSE;
GdkGLConfig *glConfig;
/*
* Configure a OpenGL-capable context.
*/
// Try to make it double-buffered.
glConfig = gdk_gl_config_new_by_mode (static_cast
(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_ALPHA | GDK_GL_MODE_DOUBLE));
if (glConfig == NULL)
{
g_print ("Cannot configure a double-buffered context.\n");
g_print ("Will try a single-buffered context.\n");
// If we can't configure a double-buffered context, try for single-buffered.
glConfig = gdk_gl_config_new_by_mode (static_cast
(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_ALPHA));
if (glConfig == NULL)
{
g_critical ("Aargh! Cannot configure any type of OpenGL-capable context. Exiting.\n");
initSuccess = FALSE;
return;
}
}
theDrawingarea = GTK_WIDGET (gtk_builder_get_object (theXml, "drawingarea1"));
// Add OpenGL-capability to the drawing area.
if (!gtk_widget_set_gl_capability (theDrawingarea, glConfig, NULL, TRUE, GDK_GL_RGBA_TYPE))
{
g_critical ("Cannot set OpenGL-capability to widget. Exiting.\n");
initSuccess = FALSE;
return;
}
// Initialise the render mutex.
theRender_mutex = g_mutex_new();
haveStatusbar = FALSE;
zmul = 1.;
}
SludgeGLApplication::~SludgeGLApplication()
{
g_mutex_free(theRender_mutex);
}
void SludgeGLApplication::setZ(float newZ)
{
z = newZ;
if (z > 200.0) z = 200.0;
if (z < -19.0) z = -19.0;
zmul = (1.0+z/20);
refreshStatusbarZmul();
}
void
SludgeGLApplication::activateZoomButtons(int picwidth, int picheight)
{
picWidth = picwidth;
picHeight = picheight;
gtk_widget_set_sensitive (GTK_WIDGET(zoom100Button), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET(zoomFitButton), TRUE);
}
void
SludgeGLApplication::deactivateZoomButtons()
{
if (zoom100Button)
gtk_widget_set_sensitive (GTK_WIDGET(zoom100Button), FALSE);
if (zoomFitButton)
gtk_widget_set_sensitive (GTK_WIDGET(zoomFitButton), FALSE);
}
void SludgeGLApplication::showStatusbar(int picwidth, int picheight)
{
picWidth = picwidth;
picHeight = picheight;
haveStatusbar = TRUE;
char buf[100];
sprintf(buf, "%i", picWidth);
gtk_label_set_text (picwLabel, buf);
sprintf(buf, "%i", picHeight);
gtk_label_set_text (pichLabel, buf);
refreshStatusbarCursor(0, 0);
refreshStatusbarZmul();
gtk_widget_show_all(statusbarWidget);
}
void SludgeGLApplication::refreshStatusbarCursor(int local_pointx, int local_pointy)
{
if (!haveStatusbar) return;
char buf[100];
sprintf(buf, "%i", (int)((local_pointx+x)*zmul));
gtk_label_set_text (cursorxLabel, buf);
sprintf(buf, "%i", (int)((local_pointy-y)*zmul));
gtk_label_set_text (cursoryLabel, buf);
}
void SludgeGLApplication::refreshStatusbarZmul()
{
if (!haveStatusbar) return;
char buf[100];
sprintf(buf, "%i", (int)(100/zmul));
gtk_label_set_text (zmulLabel, buf);
}
void SludgeGLApplication::hideStatusbar()
{
gtk_widget_hide_all(statusbarWidget);
gtk_widget_show(statusbarWidget);
}
void SludgeGLApplication::reshape()
{
if (! w) x = 0;
else x -= (theDrawingarea->allocation.width-w)/2;
if (! h) y = 0;
else y += (theDrawingarea->allocation.height-h)/2;
h = theDrawingarea->allocation.height;
w = theDrawingarea->allocation.width;
glViewport (0, 0, w, h);
setCoords();
}
void SludgeGLApplication::setCoords()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(x*zmul, (x+w)*zmul, (-y+h)*zmul, -y*zmul, 1.0, -1.0);
glMatrixMode(GL_MODELVIEW);
}
// Callbacks:
void SludgeGLApplication::on_drawingarea1_realize(GtkWidget *theWidget)
{
GdkGLContext *glContext;
GdkGLDrawable *glDrawable;
if (theWidget->window == NULL)
{
return;
}
gtk_widget_add_events(theWidget, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_SCROLL_MASK);
glContext = gtk_widget_get_gl_context (theWidget);
glDrawable = gtk_widget_get_gl_drawable (theWidget);
// Signal to gdk the start OpenGL operations.
if (!gdk_gl_drawable_gl_begin (glDrawable, glContext))
{
return;
}
glViewport (0, 0, theWidget->allocation.width, theWidget->allocation.height);
/* Your one-time OpenGL initialization code goes here */
x = y = 0;
w = theWidget->allocation.width;
h = theWidget->allocation.height;
prepareOpenGL();
// Signal to gdk we're done with OpenGL operations.
gdk_gl_drawable_gl_end (glDrawable);
gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE);
}
/*
* The "configure_event" signal handler for drawingarea1. When the area is reconfigured (such as a resize)
* this gets called - so we change the OpenGL viewport accordingly,
*/
gboolean SludgeGLApplication::on_drawingarea1_configure_event (GtkWidget *theWidget, GdkEventConfigure *theEvent)
{
GdkGLContext *glContext;
GdkGLDrawable *glDrawable;
// Don't continue if we get fed a dud window type.
if (theWidget->window == NULL)
{
return FALSE;
}
/*
* Wait until the rendering process is complete before issuing a context change,
* then lock it - to prevent possible driver issues on long rendering processes.
* You can add a timeout here or g_mutex_trylock according to taste.
*/
g_mutex_lock(theRender_mutex);
glContext = gtk_widget_get_gl_context (theWidget);
glDrawable = gtk_widget_get_gl_drawable (theWidget);
// Signal to gdk the start OpenGL operations.
if (!gdk_gl_drawable_gl_begin (glDrawable, glContext))
{
g_mutex_unlock(theRender_mutex);
return FALSE;
}
/* glViewport (0, 0, theWidget->allocation.width, theWidget->allocation.height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
*/
reshape();
glFlush ();
// Signal to gdk we're done with OpenGL operations.
gdk_gl_drawable_gl_end (glDrawable);
// Unlock the rendering mutex before sending an immediate redraw request.
g_mutex_unlock(theRender_mutex);
gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE);
gdk_window_process_updates (gtk_widget_get_parent_window (theWidget), TRUE);
// gdk_window_invalidate_rect (theWidget->window, &theWidget->allocation, FALSE);
// gdk_window_process_updates (theWidget->window, FALSE);
return FALSE;
}
/*
* The "expose_event" signal handler for drawingarea1. All OpenGL re-drawing should be done here.
* This is called every time the expose/draw event is signalled.
*
*/
gboolean SludgeGLApplication::on_drawingarea1_expose_event(GtkWidget *theWidget, GdkEventExpose *theEvent)
{
GdkGLContext *glContext;
GdkGLDrawable *glDrawable;
// Don't continue if we get fed a dud window type.
if (theWidget->window == NULL)
{
return FALSE;
}
/*
* Lock rendering mutex if it's not busy - otherwise exit.
* This prevents the renderer being spammed by drawing requests if the rendering takes longer than the feed/timer process.
*/
if (!g_mutex_trylock(theRender_mutex))
return FALSE;
glContext = gtk_widget_get_gl_context (theWidget);
glDrawable = gtk_widget_get_gl_drawable (theWidget);
// Signal to gdk the start OpenGL operations.
if (!gdk_gl_drawable_gl_begin (glDrawable, glContext))
{
g_mutex_unlock(theRender_mutex);
return FALSE;
}
drawRect();
/*
* Swap rendering buffers out (an auto glFlush is issued after) if we previously managed to initialise
* it as a double-buffered context, otherwise issue a standard glFlush call to signal we've finished
* OpenGL rendering.
*/
if (gdk_gl_drawable_is_double_buffered (glDrawable))
gdk_gl_drawable_swap_buffers (glDrawable);
else
glFlush ();
// Signal to gdk we're done with OpenGL operations.
gdk_gl_drawable_gl_end (glDrawable);
// Release the rendering mutex.
g_mutex_unlock(theRender_mutex);
return FALSE;
}
/*
* The timer-based process that operates on some variables then invalidates drawingarea1's region to trigger
* an expose_event, thus invoking function "on_drawingarea1_expose_event" through the window manager.
*
*/
gboolean SludgeGLApplication::render_timer_event(gpointer theUser_data)
{
GtkWidget *theWidget = GTK_WIDGET (theUser_data);
/*
* Only send a redraw request if the render process is not busy. This prevents long rendering processes
* from piling up.
*/
if (g_mutex_trylock(theRender_mutex))
{
// Unlock the mutex before we issue the redraw.
g_mutex_unlock(theRender_mutex);
// Invalidate drawingarea1's region to signal the window handler there needs to be an update in that area,
gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE);
// gdk_window_invalidate_rect (theWidget->window, &theWidget->allocation, FALSE);
/*
* Force an immediate update - we can omit this and leave the window manager to call the redraw when the
* main loop is idle. However, we get smoother, more consistent updates this way.
*/
gdk_window_process_updates (gtk_widget_get_parent_window (theWidget), TRUE);
// gdk_window_process_updates (theWidget->window, FALSE);
}
return TRUE;
}
gboolean SludgeGLApplication::on_drawingarea1_scroll_event(GtkWidget *theWidget, GdkEventScroll *theEvent)
{
float deltaY;
if (theEvent->direction == GDK_SCROLL_UP) {
deltaY = -1.;
}
if (theEvent->direction == GDK_SCROLL_DOWN) {
deltaY = 1.;
}
double x1, y1;
int local_pointx, local_pointy;
local_pointx = theEvent->x;
local_pointy = theEvent->y;
x1 = zmul*(local_pointx+x);
y1 = -zmul*(local_pointy-y);
setZ(z+deltaY);
x = -(local_pointx)+x1/zmul;
y = (local_pointy)+y1/zmul;
setCoords();
render_timer_event(theDrawingarea);
return FALSE;
}
gboolean SludgeGLApplication::on_drawingarea1_button_press_event
(GtkWidget *theWidget, GdkEventButton *theEvent)
{
if (theEvent->button == 1) {
button1Press (theEvent->x, theEvent->y);
}
else
{
mouseLoc2x = theEvent->x;
mouseLoc2y = theEvent->y;
awaitButton2Release = TRUE;
}
return FALSE;
}
gboolean SludgeGLApplication::on_drawingarea1_button_release_event
(GtkWidget *theWidget, GdkEventButton *theEvent)
{
if ( !((awaitButton1Release && theEvent->button == 1) || awaitButton2Release) ) return FALSE;
if (theEvent->button == 1)
{
button1Release (theEvent->x, theEvent->y);
}
else
{
awaitButton2Release = FALSE;
}
render_timer_event(theDrawingarea);
return FALSE;
}
gboolean SludgeGLApplication::on_drawingarea1_motion_notify_event
(GtkWidget *theWidget, GdkEventMotion *theEvent)
{
refreshStatusbarCursor(theEvent->x, theEvent->y);
if ( (awaitButton1Release && theEvent->state & GDK_BUTTON1_MASK) || awaitButton2Release )
{
int local_pointx, local_pointy;
local_pointx = theEvent->x;
local_pointy = theEvent->y;
if (theEvent->state & GDK_BUTTON1_MASK)
{
button1Motion (local_pointx, local_pointy);
}
else if (awaitButton2Release)
{
int x1 = x;
int y1 = y;
x = x1 + (mouseLoc2x - local_pointx);
y = y1 + (local_pointy - mouseLoc2y);
setCoords();
mouseLoc2x = theEvent->x;
mouseLoc2y = theEvent->y;
}
render_timer_event(theDrawingarea);
}
gdk_event_request_motions (theEvent);
return FALSE;
}
gboolean SludgeGLApplication::on_drawingarea1_leave_notify_event
(GtkWidget *theWidget, GdkEventAny *theEvent)
{
awaitButton1Release = FALSE;
awaitButton2Release = FALSE;
drawingareaLeft ();
return FALSE;
}
void SludgeGLApplication::on_zoom_100_realize (GtkToolButton *theButton)
{
gtk_widget_set_sensitive (GTK_WIDGET(theButton), FALSE);
zoom100Button = theButton;
}
void SludgeGLApplication::on_zoom_fit_realize (GtkToolButton *theButton)
{
gtk_widget_set_sensitive (GTK_WIDGET(theButton), FALSE);
zoomFitButton = theButton;
}
void SludgeGLApplication::on_zoom_100_clicked ()
{
setZ(0.);
x = -(w - picWidth / zmul) / 2.;
y = (h - picHeight / zmul) / 2.;
reshape();
}
void SludgeGLApplication::on_zoom_fit_clicked ()
{
float zmulx, zmuly;
zmulx = (float) picWidth / w;
zmuly = (float) picHeight / h;
if (zmulx > zmuly) {
zmul = zmulx;
x = 0;
y = (h - picHeight / zmul) / 2.;
} else {
zmul = zmuly;
x = -(w - picWidth / zmul) / 2.;
y = 0;
}
z = 20. * (zmul - 1.);
refreshStatusbarZmul();
reshape();
}
sludge-2.2/GTK_Dev_Kit/SludgeProjectManager.cpp 0000644 0001750 0001750 00000073642 11700301464 016374 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeProjectManager.cpp - Part of the SLUDGE Project Manager (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#include
#include
#include
#include "project.hpp"
#include "settings.h"
#include "interface.h"
#include "compiler.hpp"
#include "moreio.h"
#include "helpers.h"
#include "errorlinktofile.h"
#include "Common.h"
#include "SludgeProjectManager.h"
#include "ProjectManagerMain.h"
extern char * gameFile;
SludgeProjectManager::SludgeProjectManager()
: SludgeApplication(joinTwoStrings(DATADIR, "ProjectManager.glade"), "ProjIcon", "projectmanager")
{
if (!initSuccess) return;
resourceList[0] = NULL;
fileList[0] = NULL;
filesListStore = NULL;
resourcesListStore = NULL;
errorsListStore = NULL;
filesSelection = NULL;
notebook = GTK_NOTEBOOK (gtk_builder_get_object(theXml, "notebook"));
saveItem = GTK_WIDGET (gtk_builder_get_object(theXml, "save"));
saveAsItem = GTK_WIDGET (gtk_builder_get_object(theXml, "save_as"));
projectPropertiesItem = GTK_WIDGET (gtk_builder_get_object(theXml, "project_properties"));
projectCompileItem = GTK_WIDGET (gtk_builder_get_object(theXml, "project_compile"));
projectRunGameItem = GTK_WIDGET (gtk_builder_get_object(theXml, "project_run_game"));
addFileButton = GTK_WIDGET (gtk_builder_get_object(theXml, "add_file"));
removeFileButton = GTK_WIDGET (gtk_builder_get_object(theXml, "remove_file"));
compilerDialog = GTK_DIALOG (gtk_builder_get_object(theXml, "compiler_dialog"));
compProgress1 = GTK_PROGRESS_BAR (gtk_builder_get_object(theXml, "progressbar1"));
compProgress2 = GTK_PROGRESS_BAR (gtk_builder_get_object(theXml, "progressbar2"));
compTask = GTK_LABEL (gtk_builder_get_object(theXml, "comp_task"));
compFile = GTK_LABEL (gtk_builder_get_object(theXml, "comp_file"));
compItem = GTK_LABEL (gtk_builder_get_object(theXml, "comp_item"));
compFuncs = GTK_LABEL (gtk_builder_get_object(theXml, "comp_funcs"));
compObjs = GTK_LABEL (gtk_builder_get_object(theXml, "comp_objs"));
compGlobs = GTK_LABEL (gtk_builder_get_object(theXml, "comp_globs"));
compStrings = GTK_LABEL (gtk_builder_get_object(theXml, "comp_strings"));
compResources = GTK_LABEL (gtk_builder_get_object(theXml, "comp_resources"));
runGameButton = GTK_WIDGET (gtk_builder_get_object(theXml, "comp_gamebutton"));
closeCompilerButton = GTK_WIDGET (gtk_builder_get_object(theXml, "comp_okbutton"));
projectSettingsDialog = GTK_DIALOG (gtk_builder_get_object(theXml, "project_settings_dialog"));
prefName = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_name"));
prefQuit = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_quit"));
prefSave = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_save"));
prefLanguage = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_language"));
prefFilename = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_filename"));
prefIcon = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_icon"));
prefLogo = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_logo"));
prefWidth = GTK_SPIN_BUTTON (gtk_builder_get_object(theXml, "pref_width"));
prefHeight = GTK_SPIN_BUTTON (gtk_builder_get_object(theXml, "pref_height"));
prefSpeed = GTK_SPIN_BUTTON (gtk_builder_get_object(theXml, "pref_speed"));
prefSilent = GTK_TOGGLE_BUTTON (gtk_builder_get_object(theXml, "pref_silent"));
preferenceDialog = GTK_DIALOG (gtk_builder_get_object(theXml, "preferences_dialog"));
prefKeepImages = GTK_TOGGLE_BUTTON (gtk_builder_get_object(theXml, "pref_keep_images"));
prefWriteStrings = GTK_TOGGLE_BUTTON (gtk_builder_get_object(theXml, "pref_write_strings"));
prefVerbose = GTK_TOGGLE_BUTTON (gtk_builder_get_object(theXml, "pref_verbose"));
prefEditor = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_editor"));
prefImageViewer = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_image_viewer"));
prefAudioPlayer = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_audio_player"));
prefModPlayer = GTK_ENTRY (gtk_builder_get_object(theXml, "pref_mod_player"));
compilerInfoQueue = NULL;
if (!getcwd(workingDir, 998))
fprintf(stderr, "Couldn't get current working directory.");
readIniFile();
init(TRUE);
setupButtons();
}
SludgeProjectManager::~SludgeProjectManager()
{
closeProject(fileList, &fileListNum);
}
// Concrete methods for SludgeApplication:
gboolean SludgeProjectManager::init(gboolean calledFromConstructor)
{
currentFilename[0] = 0;
sprintf(currentShortname, "%s", getUntitledFilename());
return FALSE;
}
const char * SludgeProjectManager::getWindowTitle()
{
return "SLUDGE Project Manager";
}
const char * SludgeProjectManager::getFilterName()
{
return "SLUDGE Project Files (*.slp)";
}
const char * SludgeProjectManager::getFilterPattern()
{
return "*.[sS][lL][pP]";
}
const char * SludgeProjectManager::getUntitledFilename()
{
return "Untitled Project.slp";
}
gboolean SludgeProjectManager::saveFile(char *filename)
{
return saveProject(filename, fileList, &fileListNum);
}
gboolean SludgeProjectManager::loadFile(char *filename)
{
return loadProject(filename, fileList, &fileListNum);
}
void SludgeProjectManager::postOpen()
{
listChanged(FILE_TREEVIEW);
setupButtons();
gtk_widget_set_sensitive(projectRunGameItem, FALSE);
}
void SludgeProjectManager::postNew()
{
GtkWidget *dialog;
GtkFileFilter *filter;
gboolean success = FALSE;
dialog = gtk_file_chooser_dialog_new("New SLUDGE Project",
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (dialog), TRUE);
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, getFilterName());
gtk_file_filter_add_pattern(filter, getFilterPattern());
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (dialog), getUntitledFilename());
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
flipBackslashes(&filename);
doNewProject(filename, fileList, &fileListNum);
listChanged(FILE_TREEVIEW);
listChanged(RESOURCE_TREEVIEW);
gtk_list_store_clear(errorsListStore);
gtk_widget_set_sensitive(projectRunGameItem, FALSE);
setFilename(filename);
setFolderFromFilename(filename);
g_free(filename);
success = TRUE;
}
gtk_widget_destroy(dialog);
if (success)
on_project_settings();
setupButtons();
}
void SludgeProjectManager::setupButtons()
{
if (currentFilename[0] == 0) {
gtk_widget_set_sensitive(saveItem, FALSE);
gtk_widget_set_sensitive(saveAsItem, FALSE);
gtk_widget_set_sensitive(projectPropertiesItem, FALSE);
gtk_widget_set_sensitive(addFileButton, FALSE);
gtk_widget_set_sensitive(removeFileButton, FALSE);
} else {
gtk_widget_set_sensitive(saveItem, TRUE);
gtk_widget_set_sensitive(saveAsItem, TRUE);
gtk_widget_set_sensitive(projectPropertiesItem, TRUE);
gtk_widget_set_sensitive(addFileButton, TRUE);
}
if (fileListNum) {
gtk_widget_set_sensitive(projectCompileItem, TRUE);
} else {
gtk_widget_set_sensitive(projectCompileItem, FALSE);
}
}
void SludgeProjectManager::listChanged(whichTreeview whichOne)
{
GtkListStore *listStore;
int numItems;
char **list;
switch (whichOne) {
case FILE_TREEVIEW:
listStore = filesListStore;
numItems = fileListNum;
list = fileList;
break;
case RESOURCE_TREEVIEW:
listStore = resourcesListStore;
numItems = numResources;
list = resourceList;
break;
case ERROR_TREEVIEW:
listStore = errorsListStore;
numItems = numErrors;
break;
default:
break;
}
gtk_list_store_clear(listStore);
int i, j;
char *listitem;
struct errorLinkToFile * index;
for (i = 0; i < numItems; i++) {
GtkTreeIter iter;
gtk_list_store_append(listStore, &iter);
switch (whichOne) {
case FILE_TREEVIEW:
case RESOURCE_TREEVIEW:
{
listitem = g_filename_to_utf8(list[i], -1, NULL, NULL, NULL);
gtk_list_store_set(listStore, &iter, 0, listitem, -1);
g_free(listitem);
listitem = NULL;
break;
}
case ERROR_TREEVIEW:
{
index = errorList;
if (! index) return;
j = numErrors-1;
while (j>i) {
if (! (index = index->next)) return;
j--;
}
listitem = g_locale_to_utf8(index->fullText, -1, NULL, NULL, NULL);
gtk_list_store_set(listStore, &iter, ERRORS_COLUMN_FULLTEXT, listitem, -1);
g_free(listitem);
listitem = NULL;
if (index->filename) {
gtk_list_store_set(listStore, &iter, ERRORS_COLUMN_HAS_FILENAME, TRUE, -1);
listitem = g_filename_to_utf8(index->filename, -1, NULL, NULL, NULL);
gtk_list_store_set(listStore, &iter, ERRORS_COLUMN_FILENAME, listitem, -1);
g_free(listitem);
listitem = NULL;
} else {
gtk_list_store_set(listStore, &iter, ERRORS_COLUMN_HAS_FILENAME, FALSE, -1);
listitem = g_locale_to_utf8(index->overview, -1, NULL, NULL, NULL);
gtk_list_store_set(listStore, &iter, ERRORS_COLUMN_OVERVIEW, listitem, -1);
g_free(listitem);
listitem = NULL;
}
break;
}
default:
break;
}
}
}
void SludgeProjectManager::readIniFile() {
if (g_chdir(g_get_user_config_dir())) return;
#ifdef __WIN32
_mkdir("sludge-devkit");
#else
g_mkdir("sludge-devkit", 0000777);
#endif
g_chdir("sludge-devkit");
FILE * fp = fopen("SLUDGE.ini", "rb");
programSettings.compilerKillImages = 0;
programSettings.compilerWriteStrings = 0;
programSettings.compilerVerbose = 1;
programSettings.searchSensitive = 0;
#ifdef __WIN32
sprintf(editor, "%s", "notepad.exe");
sprintf(imageViewer, "%s", "rundll32.exe shimgvw.dll,ImageView_Fullscreen");
sprintf(audioPlayer, "%s", "mplay32.exe");
sprintf(modPlayer, "%s", "");
#else
sprintf(editor, "%s", "gedit");
sprintf(imageViewer, "%s", "eog");
sprintf(audioPlayer, "%s", "totem");
sprintf(modPlayer, "%s", "totem");
#endif
if (fp) {
char lineSoFar[257] = "";
char secondSoFar[257] = "";
unsigned char here = 0;
char readChar = ' ';
bool keepGoing = true;
bool doingSecond = false;
do {
readChar = fgetc(fp);
if (feof(fp)) {
readChar = '\x0D';
keepGoing = false;
}
switch (readChar) {
case '\x0D':
case '\x0A':
if (!keepGoing) {
fprintf(fp, "KillImages=%d\x0D\x0A", programSettings.compilerKillImages);
fprintf(fp, "WriteStrings=%d\x0D\x0A", programSettings.compilerWriteStrings);
fprintf(fp, "Verbose=%d\x0D\x0A", programSettings.compilerVerbose);
fprintf(fp, "SearchSensitive=%d\x0D\x0A", programSettings.searchSensitive);
fprintf(fp, "Editor=%s\x0D\x0A", editor);
fprintf(fp, "ImageViewer=%s\x0D\x0A", imageViewer);
fprintf(fp, "AudioPlayer=%s\x0D\x0A", audioPlayer);
fprintf(fp, "ModPlayer=%s\x0D\x0A", modPlayer);
}
if (doingSecond) {
if (strcmp(lineSoFar, "KillImages") == 0)
{
programSettings.compilerKillImages = atoi(secondSoFar);
}
else if (strcmp(lineSoFar, "WriteStrings") == 0)
{
programSettings.compilerWriteStrings = atoi(secondSoFar);
}
else if (strcmp(lineSoFar, "Verbose") == 0)
{
programSettings.compilerVerbose = atoi(secondSoFar);
}
else if (strcmp(lineSoFar, "SearchSensitive") == 0)
{
programSettings.searchSensitive = atoi(secondSoFar);
}
else if (strcmp(lineSoFar, "Editor") == 0)
{
sprintf(editor, "%s", secondSoFar);
}
else if (strcmp(lineSoFar, "ImageViewer") == 0)
{
sprintf(imageViewer, "%s", secondSoFar);
}
else if (strcmp(lineSoFar, "AudioPlayer") == 0)
{
sprintf(audioPlayer, "%s", secondSoFar);
}
else if (strcmp(lineSoFar, "ModPlayer") == 0)
{
sprintf(modPlayer, "%s", secondSoFar);
}
}
here = 0;
doingSecond = false;
lineSoFar[0] = 0;
secondSoFar[0] = 0;
break;
case '=':
doingSecond = true;
here = 0;
break;
default:
if (doingSecond) {
secondSoFar[here ++] = readChar;
secondSoFar[here] = 0;
} else {
lineSoFar[here ++] = readChar;
lineSoFar[here] = 0;
}
break;
}
} while (keepGoing);
fclose(fp);
}
g_chdir(workingDir);
}
void SludgeProjectManager::saveIniFile() {
if (g_chdir(g_get_user_config_dir())) return;
#ifdef __WIN32
_mkdir("sludge-devkit");
#else
g_mkdir("sludge-devkit", 0000777);
#endif
g_chdir("sludge-devkit");
FILE * fp = fopen("SLUDGE.ini", "wb");
fprintf(fp, "KillImages=%d\x0D\x0A", programSettings.compilerKillImages);
fprintf(fp, "WriteStrings=%d\x0D\x0A", programSettings.compilerWriteStrings);
fprintf(fp, "Verbose=%d\x0D\x0A", programSettings.compilerVerbose);
fprintf(fp, "SearchSensitive=%d\x0D\x0A", programSettings.searchSensitive);
fprintf(fp, "Editor=%s\x0D\x0A", editor);
fprintf(fp, "ImageViewer=%s\x0D\x0A", imageViewer);
fprintf(fp, "AudioPlayer=%s\x0D\x0A", audioPlayer);
fprintf(fp, "ModPlayer=%s\x0D\x0A", modPlayer);
fclose(fp);
g_chdir(workingDir);
}
void SludgeProjectManager::compile()
{
compileEverything(currentFilename, fileList, &fileListNum, &receiveCompilerInfo);
}
void SludgeProjectManager::update_compile_window()
{
char intbuf[100];
compilerInfo *info = (compilerInfo *) g_async_queue_pop(compilerInfoQueue);
if (info->progress1 > -1.)
gtk_progress_bar_set_fraction(compProgress1, info->progress1);
if (info->progress2 > -1.)
gtk_progress_bar_set_fraction(compProgress2, info->progress2);
if (info->task[0] != 0)
gtk_label_set_text(compTask, info->task);
if (info->file[0] != 0)
gtk_label_set_text(compFile, info->file);
if (info->item[0] != 0)
gtk_label_set_text(compItem, info->item);
if (info->funcs > -1) {
sprintf(intbuf, "%i", info->funcs);
gtk_label_set_text(compFuncs, intbuf);
}
if (info->objs > -1) {
sprintf(intbuf, "%i", info->objs);
gtk_label_set_text(compObjs, intbuf);
}
if (info->globs > -1) {
sprintf(intbuf, "%i", info->globs);
gtk_label_set_text(compGlobs, intbuf);
}
if (info->strings > -1) {
sprintf(intbuf, "%i", info->strings);
gtk_label_set_text(compStrings, intbuf);
}
if (info->resources > -1) {
sprintf(intbuf, "%i", info->resources);
gtk_label_set_text(compResources, intbuf);
}
if (info->newComments) {
listChanged(ERROR_TREEVIEW);
}
if (info->finished) {
gtk_label_set_text(compFile, "");
gtk_label_set_text(compItem, "");
gtk_widget_set_sensitive(closeCompilerButton, TRUE);
if (info->success) {
gtk_widget_set_sensitive(runGameButton, TRUE);
gtk_widget_set_sensitive(projectRunGameItem, TRUE);
} else {
gtk_widget_set_sensitive(projectRunGameItem, FALSE);
}
}
delete info;
}
// Callbacks:
void SludgeProjectManager::on_treeview_realize(GtkTreeView *theTreeView, whichTreeview whichOne)
{
GtkTreeModel *sortModel;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
char caption[100];
switch (whichOne) {
case FILE_TREEVIEW:
filesListStore = gtk_list_store_new(1, G_TYPE_STRING);
sortModel = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(filesListStore));
sprintf(caption, "Files in project");
filesSelection = gtk_tree_view_get_selection(theTreeView);
gtk_tree_selection_set_mode(filesSelection, GTK_SELECTION_MULTIPLE);
g_signal_connect(G_OBJECT (filesSelection), "changed",
G_CALLBACK (on_files_tree_selection_changed_cb),
NULL);
break;
case RESOURCE_TREEVIEW:
resourcesListStore = gtk_list_store_new(1, G_TYPE_STRING);
sortModel = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(resourcesListStore));
sprintf(caption, "Resources used by selected scripts");
break;
case ERROR_TREEVIEW:
errorsListStore = gtk_list_store_new(ERRORS_N_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
sortModel = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(errorsListStore));
sprintf(caption, "Compiler errors");
break;
default:
break;
}
gtk_tree_view_set_model(theTreeView, sortModel);
// Sorting lists alphabetically is commented out,
// because the order is important in some cases:
// gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (sortModel),
// 0, GTK_SORT_ASCENDING);
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(caption,
renderer,
"text", 0,
NULL);
gtk_tree_view_append_column(theTreeView, column);
}
void SludgeProjectManager::on_files_tree_selection_changed(GtkTreeSelection *theSelection)
{
GList * selectedRows;
GtkTreeIter iter;
GtkTreeModel *model;
gchar *tx, *tx1;
clearFileList(resourceList, &numResources);
if (currentFilename[0] == 0)
return;
getSourceDirFromName(currentFilename);
selectedRows = gtk_tree_selection_get_selected_rows(theSelection, &model);
for (int j = 0; j < g_list_length(selectedRows); j++)
{
gtk_tree_model_get_iter(model, &iter, (GtkTreePath *)g_list_nth(selectedRows, j)->data);
gtk_tree_model_get(model, &iter, 0, &tx1, -1);
tx = g_locale_from_utf8(tx1, -1, NULL, NULL, NULL);
g_free(tx1);
populateResourceList(tx, resourceList, &numResources);
g_free(tx);
gtk_widget_set_sensitive(removeFileButton, TRUE);
}
if (g_list_length(selectedRows) == 0) {
gtk_widget_set_sensitive(removeFileButton, FALSE);
}
g_list_foreach(selectedRows, (GFunc) gtk_tree_path_free, NULL);
g_list_free(selectedRows);
listChanged(RESOURCE_TREEVIEW);
}
void SludgeProjectManager::on_treeview_row_activated(GtkTreeView *theTreeView, GtkTreePath *thePath, GtkTreeViewColumn *theColumn, whichTreeview whichOne)
{
GtkTreeModel *treeModel;
const char *cmd;
char *tx, *tx1;
if (currentFilename[0] == 0)
return;
getSourceDirFromName(currentFilename);
gotoSourceDirectory();
treeModel = gtk_tree_view_get_model(theTreeView);
int filenameColumn = 0;
switch (whichOne) {
case ERROR_TREEVIEW:
filenameColumn = ERRORS_COLUMN_FILENAME;
case FILE_TREEVIEW:
cmd = editor;
break;
default:
break;
}
GtkTreeIter iter;
gtk_tree_model_get_iter(treeModel, &iter, thePath);
if (whichOne == ERROR_TREEVIEW) {
gboolean hasFilename;
gtk_tree_model_get(treeModel, &iter, ERRORS_COLUMN_HAS_FILENAME, &hasFilename, -1);
if (!hasFilename) {
gtk_tree_model_get(treeModel, &iter, ERRORS_COLUMN_OVERVIEW, &tx, -1);
errorBox("Error overview", tx);
g_free(tx);
return;
}
}
gtk_tree_model_get(treeModel, &iter, filenameColumn, &tx1, -1);
tx = g_filename_from_utf8(tx1, -1, NULL, NULL, NULL);
g_free(tx1);
char * extension;
gint *indices;
struct errorLinkToFile * index;
int i, row;
switch (whichOne) {
case FILE_TREEVIEW:
extension = tx + strlen(tx) - 4;
if ((strlen(tx) > 4) && (!strcmp(extension, ".tra") || !strcmp(extension, ".TRA"))) {
#ifdef __WIN32
cmd = "sludge-translationeditor.exe";
#else
cmd = "sludge-translationeditor";
#endif
}
break;
case RESOURCE_TREEVIEW:
extension = tx + strlen(tx) - 4;
if (strlen(tx) > 4) {
if (!strcmp(extension, ".flo") || !strcmp(extension, ".FLO")) {
#ifdef __WIN32
cmd = "sludge-floormaker.exe";
#else
cmd = "sludge-floormaker";
#endif
} else if (!strcmp(extension, ".duc") || !strcmp(extension, ".DUC")) {
#ifdef __WIN32
cmd = "sludge-spritebankeditor.exe";
#else
cmd = "sludge-spritebankeditor";
#endif
} else if (!strcmp(extension, ".zbu") || !strcmp(extension, ".ZBU")) {
#ifdef __WIN32
cmd = "sludge-zbuffermaker.exe";
#else
cmd = "sludge-zbuffermaker";
#endif
} else if (!strcmp(extension, ".png") || !strcmp(extension, ".PNG")
|| !strcmp(extension, ".tga") || !strcmp(extension, ".TGA")) {
cmd = imageViewer;
} else if (!strcmp(extension, ".wav") || !strcmp(extension, ".WAV")
|| !strcmp(extension, ".ogg") || !strcmp(extension, ".OGG")
|| !strcmp(extension, "flac") || !strcmp(extension, "FLAC")) {
cmd = audioPlayer;
} else if (!strcmp(extension, ".mod") || !strcmp(extension, ".MOD")
|| !strcmp(extension, ".s3m") || !strcmp(extension, ".S3M")) {
cmd = modPlayer;
} else {
extension = tx + strlen(tx) - 3;
if (strlen(tx) > 3 &&
(!strcmp(extension, ".it") || !strcmp(extension, ".IT")
|| !strcmp(extension, ".xm") || !strcmp(extension, ".XM"))) {
cmd = modPlayer;
}
}
}
break;
default:
break;
}
if (cmd[0] != 0 && tx) {
sh_cmd(workingDir, cmd, getFullPath(tx));
}
/*
else {
char buf[1000];
GError *error = NULL;
sprintf(buf, "file://%s", getFullPath(tx));
gtk_show_uri (NULL, buf, GDK_CURRENT_TIME, &error);
if (error != NULL) {
errorBox("Opening file failed!", error->message);
g_error_free(error);
}
}
*/
g_free(tx);
}
void SludgeProjectManager::on_add_file_clicked()
{
GtkWidget *dialog;
GtkFileFilter *filter, *slufilter, *sldfilter, *trafilter;
dialog = gtk_file_chooser_dialog_new("Add file to SLUDGE project",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, "SLU/SLD/TRA files");
gtk_file_filter_add_pattern(filter, "*.[sS][lL][uU]");
gtk_file_filter_add_pattern(filter, "*.[sS][lL][dD]");
gtk_file_filter_add_pattern(filter, "*.[tT][rR][aA]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filter);
slufilter = gtk_file_filter_new();
gtk_file_filter_set_name(slufilter, "SLUDGE scripts (*.slu)");
gtk_file_filter_add_pattern(slufilter, "*.[sS][lL][uU]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), slufilter);
sldfilter = gtk_file_filter_new();
gtk_file_filter_set_name(sldfilter, "SLUDGE constant definition files (*.sld)");
gtk_file_filter_add_pattern(sldfilter, "*.[sS][lL][dD]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), sldfilter);
trafilter = gtk_file_filter_new();
gtk_file_filter_set_name(trafilter, "SLUDGE translation files (*.tra)");
gtk_file_filter_add_pattern(trafilter, "*.[tT][rR][aA]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), trafilter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER (dialog), TRUE);
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
GSList *filenames;
char *filename;
filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER (dialog));
for (int j = 0; j < g_slist_length(filenames); j++) {
filename = (char *) g_slist_nth(filenames, j)->data;
flipBackslashes(&filename);
getSourceDirFromName(currentFilename);
addFileToProject(filename, sourceDirectory, fileList, &fileListNum);
setFileChanged();
g_free(filename);
}
g_slist_free(filenames);
}
gtk_widget_destroy(dialog);
listChanged(FILE_TREEVIEW);
}
void SludgeProjectManager::on_remove_file_clicked()
{
GList * selectedRows;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
gchar *indexStr;
int index;
if (! askAQuestion("Remove files?", "Do you want to remove the selected files from the project? (They will not be deleted from the disk.)")) {
return;
}
selectedRows = gtk_tree_selection_get_selected_rows(filesSelection, &model);
for (int j = g_list_length(selectedRows) - 1; j >= 0; j--)
{
path = gtk_tree_model_sort_convert_path_to_child_path(
GTK_TREE_MODEL_SORT(model),
(GtkTreePath *)g_list_nth(selectedRows, j)->data);
indexStr = gtk_tree_path_to_string(path);
index = atoi(indexStr);
g_free(indexStr);
removeFileFromList(index, fileList, &fileListNum);
setFileChanged();
gtk_tree_model_get_iter(GTK_TREE_MODEL(filesListStore), &iter, path);
gtk_list_store_remove(filesListStore, &iter);
}
g_list_foreach(selectedRows, (GFunc) gtk_tree_path_free, NULL);
g_list_free(selectedRows);
}
void SludgeProjectManager::on_compile()
{
//Switch to the "Compiler Errors" notebook to make sure the TableView is realized:
gtk_notebook_set_current_page(notebook, 1);
gtk_widget_set_sensitive(closeCompilerButton, FALSE);
gtk_widget_set_sensitive(runGameButton, FALSE);
gtk_widget_show(GTK_WIDGET(compilerDialog));
compilerInfoQueue = g_async_queue_new();
GError *error = NULL;
gdk_threads_leave ();
g_thread_create(compile_hook, NULL, FALSE, &error);
gdk_threads_enter ();
if (error != NULL) {
errorBox("Could not create a new thread for compiling!", error->message);
g_error_free(error);
return;
}
}
void SludgeProjectManager::on_comp_okbutton_clicked(GtkButton *theButton)
{
GtkWidget *theDialog;
theDialog = gtk_widget_get_toplevel(GTK_WIDGET(theButton));
gtk_widget_hide(theDialog);
}
void SludgeProjectManager::on_comp_gamebutton_clicked()
{
char cmd[1000];
char *file = getFullPath(gameFile);
#ifdef __WIN32
int cmdSuccess;
int lastSlash = 0;
char engineDir[1000];
sprintf(engineDir, "%s", workingDir);
for (int k = 0; engineDir[k] != 0; k++) {
if (engineDir[k] == '\\') {
lastSlash = k;
}
}
sprintf(engineDir + lastSlash + 1, "Engine");
sprintf(cmd, "\"%s\\SLUDGE Engine.exe\"", engineDir);
cmdSuccess = sh_cmd(engineDir, cmd, file);
if (!cmdSuccess) {
errorBox("Couldn't find SLUDGE Engine", "The SLUDGE Engine was expected at ..\\Engine\\SLUDGE Engine.exe relative to the Project Manager executable. Make sure it's there to make the Run Game button work.");
}
#else
sprintf(cmd, "%s", "sludge-engine");
sh_cmd(workingDir, cmd, file);
#endif
deleteString(file);
}
void SludgeProjectManager::on_project_settings()
{
gtk_entry_set_text(prefName, settings.windowName ? settings.windowName : "");
gtk_entry_set_text(prefQuit, settings.quitMessage ? settings.quitMessage : "");
gtk_entry_set_text(prefSave, settings.runtimeDataFolder ? settings.runtimeDataFolder : "");
gtk_entry_set_text(prefLanguage, settings.originalLanguage ? settings.originalLanguage : "");
gtk_entry_set_text(prefFilename, settings.finalFile ? settings.finalFile : "");
gtk_entry_set_text(prefIcon, settings.customIcon ? settings.customIcon : "");
gtk_entry_set_text(prefLogo, settings.customLogo ? settings.customLogo : "");
gtk_spin_button_set_value(prefWidth, (double)settings.screenWidth);
gtk_spin_button_set_value(prefHeight, (double)settings.screenHeight);
gtk_spin_button_set_value(prefSpeed, (double)settings.frameSpeed);
gtk_toggle_button_set_active(prefSilent, settings.forceSilent);
if (gtk_dialog_run(projectSettingsDialog) == GTK_RESPONSE_OK)
{
killSettingsStrings();
settings.quitMessage = copyString(gtk_entry_get_text(prefQuit));
settings.customIcon = copyString(gtk_entry_get_text(prefIcon));
settings.customLogo = copyString(gtk_entry_get_text(prefLogo));
settings.runtimeDataFolder = copyString(gtk_entry_get_text(prefSave));
settings.finalFile = copyString(gtk_entry_get_text(prefFilename));
settings.windowName = copyString(gtk_entry_get_text(prefName));
settings.originalLanguage = copyString(gtk_entry_get_text(prefLanguage));
settings.screenHeight = gtk_spin_button_get_value_as_int(prefHeight);
settings.screenWidth = gtk_spin_button_get_value_as_int(prefWidth);
settings.frameSpeed = gtk_spin_button_get_value_as_int(prefSpeed);
settings.forceSilent = gtk_toggle_button_get_active(prefSilent);
setFileChanged();
}
gtk_widget_hide(GTK_WIDGET(projectSettingsDialog));
}
void SludgeProjectManager::on_preferences()
{
gtk_toggle_button_set_active(prefKeepImages, !programSettings.compilerKillImages);
gtk_toggle_button_set_active(prefWriteStrings, programSettings.compilerWriteStrings);
gtk_toggle_button_set_active(prefVerbose, programSettings.compilerVerbose);
gtk_entry_set_text(prefEditor, editor ? editor : "");
gtk_entry_set_text(prefImageViewer, imageViewer ? imageViewer : "");
gtk_entry_set_text(prefAudioPlayer, audioPlayer ? audioPlayer : "");
gtk_entry_set_text(prefModPlayer, modPlayer ? modPlayer : "");
if (gtk_dialog_run(preferenceDialog) == GTK_RESPONSE_OK)
{
programSettings.compilerKillImages = !gtk_toggle_button_get_active(prefKeepImages);
programSettings.compilerWriteStrings = gtk_toggle_button_get_active(prefWriteStrings);
programSettings.compilerVerbose = gtk_toggle_button_get_active(prefVerbose);
sprintf(editor, "%s", gtk_entry_get_text(prefEditor));
sprintf(imageViewer, "%s", gtk_entry_get_text(prefImageViewer));
sprintf(audioPlayer, "%s", gtk_entry_get_text(prefAudioPlayer));
sprintf(modPlayer, "%s", gtk_entry_get_text(prefModPlayer));
saveIniFile();
}
gtk_widget_hide(GTK_WIDGET(preferenceDialog));
}
void SludgeProjectManager::on_program_activate(whichProgram program)
{
const char *exe;
char executable[200];
#ifdef __WIN32
exe = ".exe";
#else
exe = "";
#endif
switch (program) {
case FLOORMAKER:
sprintf(executable, "sludge-floormaker%s", exe);
break;
case SPRITEBANKEDITOR:
sprintf(executable, "sludge-spritebankeditor%s", exe);
break;
case ZBUFFERMAKER:
sprintf(executable, "sludge-zbuffermaker%s", exe);
break;
case TRANSLATIONEDITOR:
sprintf(executable, "sludge-translationeditor%s", exe);
break;
default:
break;
}
sh_cmd(workingDir, executable, NULL);
}
sludge-2.2/GTK_Dev_Kit/SludgeTranslationEditor.cpp 0000644 0001750 0001750 00000041004 11700301634 017122 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeTranslationEditor.cpp - Part of the SLUDGE Translation Editor (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#include
#include
#include
#include "translator.h"
#include "moreio.h"
#include "Common.h"
#include "SludgeTranslationEditor.h"
#include "TranslationEditorMain.h"
SludgeTranslationEditor::SludgeTranslationEditor()
: SludgeApplication(joinTwoStrings(DATADIR, "TranslationEditor.glade"), "flags", "translationeditor")
{
if (!initSuccess) return;
firstTransLine = NULL;
langName = NULL;
comboBox = NULL;
listStore = NULL;
filterModel = NULL;
sortModel = NULL;
selection = NULL;
originalColumn = NULL;
translationColumn = NULL;
theIdAdjustment = GTK_ADJUSTMENT (gtk_builder_get_object(theXml, "id_adjustment"));
theLanguageEntry = GTK_ENTRY (gtk_builder_get_object(theXml, "language_name"));
theSearchEntry = GTK_ENTRY (gtk_builder_get_object(theXml, "search_entry"));
theOriginalTextBuffer = GTK_TEXT_BUFFER (gtk_builder_get_object(theXml, "original_textbuffer"));
theTranslationTextBuffer = GTK_TEXT_BUFFER (gtk_builder_get_object(theXml, "translation_textbuffer"));
init(TRUE);
}
// Concrete methods for SludgeApplication:
gboolean SludgeTranslationEditor::init(gboolean calledFromConstructor)
{
currentFilename[0] = 0;
sprintf(currentShortname, "%s", getUntitledFilename());
badLangName = FALSE;
return FALSE;
}
const char * SludgeTranslationEditor::getWindowTitle()
{
return "SLUDGE Translation Editor";
}
const char * SludgeTranslationEditor::getFilterName()
{
return "SLUDGE Translation Files (*.tra)";
}
const char * SludgeTranslationEditor::getFilterPattern()
{
return "*.[tT][rR][aA]";
}
const char * SludgeTranslationEditor::getUntitledFilename()
{
return "Untitled Translation.tra";
}
gboolean SludgeTranslationEditor::saveFile(char *filename)
{
return saveTranslationFile (filename, firstTransLine, gtk_entry_get_text(theLanguageEntry), (unsigned int)gtk_adjustment_get_value(theIdAdjustment));
}
gboolean SludgeTranslationEditor::loadFile(char *filename)
{
unsigned int langID;
if (loadTranslationFile(filename, &firstTransLine, &langName, &langID)) {
gtk_adjustment_set_value(theIdAdjustment, (double)langID);
if (langName) {
if (g_utf8_validate(langName, -1, NULL)) {
badLangName = FALSE;
gtk_entry_set_text(theLanguageEntry, langName);
} else {
badLangName = TRUE;
}
deleteString(langName);
langName = NULL;
}
return TRUE;
} else {
return FALSE;
}
}
void SludgeTranslationEditor::postOpen()
{
listChanged();
}
void SludgeTranslationEditor::postNew()
{
newFile(&firstTransLine);
gtk_adjustment_set_value(theIdAdjustment, 0.);
gtk_entry_set_text(theLanguageEntry, "");
listChanged();
}
void SludgeTranslationEditor::listChanged()
{
char *listitem, *stringPtr;
GtkTreeIter iter;
int stringId = 0;
gtk_list_store_clear(listStore);
gboolean badChars = FALSE;
int type = gtk_combo_box_get_active(comboBox);
struct transLine * line = firstTransLine;
while (line) {
gtk_list_store_append(listStore, &iter);
for (int k = 0; k < 2; k++) {
stringPtr = k?line->transTo:line->transFrom;
if (!stringPtr) continue;
if (g_utf8_validate(stringPtr, -1, NULL)) {
gtk_list_store_set(listStore, &iter, 2*k, stringPtr, -1);
} else {
badChars = TRUE;
}
}
gtk_list_store_set(listStore, &iter, COLUMN_TRANSLATE, line?line->type != TYPE_NONE:FALSE, -1);
gtk_list_store_set(listStore, &iter, COLUMN_ID, stringId, -1);
gtk_list_store_set(listStore, &iter, COLUMN_VISIBLE, TRUE, -1);
stringId++;
line = line->next;
}
if (badChars || badLangName) {
on_new();
errorBox("Invalid characters!", "The translation file or SLUDGE scripts in the project contain characters that are encoded in something else than UTF-8. Starting with SLUDGE 2.2 all SLUDGE scripts have to be UTF-8 encoded. Please convert your files.");
}
}
// Callbacks:
void SludgeTranslationEditor::on_combobox_realize(GtkComboBox *theComboBox)
{
GtkListStore *comboStore;
GtkCellRenderer *cellRenderer;
GtkTreeIter iter, iter1;
comboBox = theComboBox;
comboStore = gtk_list_store_new(1, G_TYPE_STRING);
gtk_list_store_append(comboStore, &iter1);
gtk_list_store_set(comboStore, &iter1, 0, "Show all strings", -1);
gtk_list_store_append(comboStore, &iter);
gtk_list_store_set(comboStore, &iter, 0, "Show strings that are missing translations", -1);
gtk_list_store_append(comboStore, &iter);
gtk_list_store_set(comboStore, &iter, 0, "Show translated strings", -1);
gtk_list_store_append(comboStore, &iter);
gtk_list_store_set(comboStore, &iter, 0, "Show strings that don't need translation", -1);
gtk_combo_box_set_model(theComboBox, GTK_TREE_MODEL(comboStore));
cellRenderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( theComboBox ), cellRenderer, TRUE );
gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( theComboBox ), cellRenderer, "text", 0, NULL );
gtk_combo_box_set_active_iter(theComboBox, &iter1);
}
void SludgeTranslationEditor::on_combobox_changed(GtkComboBox *theComboBox)
{
if (listStore) {
int type = gtk_combo_box_get_active(theComboBox);
GtkTreeIter iter;
if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(listStore), &iter, "0")) {
return;
}
struct transLine * line = firstTransLine;
while (line) {
if ( (type == 0) ||
(type == 1 && line->type == TYPE_NEW) ||
(type == 2 && line->type == TYPE_TRANS) ||
(type == 3 && line->type == TYPE_NONE) )
{
gtk_list_store_set(listStore, &iter, COLUMN_VISIBLE, TRUE, -1);
} else {
gtk_list_store_set(listStore, &iter, COLUMN_VISIBLE, FALSE, -1);
}
gtk_tree_model_iter_next(GTK_TREE_MODEL(listStore), &iter);
line = line->next;
}
}
}
void SludgeTranslationEditor::on_treeview_realize(GtkTreeView *theTreeView)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
char caption[100];
listStore = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
filterModel = gtk_tree_model_filter_new(GTK_TREE_MODEL(listStore), NULL);
gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(filterModel), COLUMN_VISIBLE);
sortModel = gtk_tree_model_sort_new_with_model(filterModel);
gtk_tree_view_set_model(theTreeView, sortModel);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (sortModel),
COLUMN_ID, GTK_SORT_ASCENDING);
selection = gtk_tree_view_get_selection(theTreeView);
g_signal_connect(G_OBJECT (selection), "changed",
G_CALLBACK (on_tree_selection_changed_cb),
NULL);
sprintf(caption, "Original text");
renderer = gtk_cell_renderer_text_new();
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
originalColumn = gtk_tree_view_column_new_with_attributes(caption,
renderer,
"text", COLUMN_ORIGINAL,
NULL);
gtk_tree_view_column_set_clickable(originalColumn, TRUE);
g_signal_connect(G_OBJECT (originalColumn), "clicked",
G_CALLBACK (on_sort_original_clicked_cb),
NULL);
gtk_tree_view_column_set_expand(originalColumn, TRUE);
gtk_tree_view_append_column(theTreeView, originalColumn);
sprintf(caption, "Translate?");
renderer = gtk_cell_renderer_toggle_new();
g_signal_connect(G_OBJECT (renderer), "toggled",
G_CALLBACK (on_translate_toggled_cb),
NULL);
column = gtk_tree_view_column_new_with_attributes(caption,
renderer,
"active", COLUMN_TRANSLATE,
NULL);
gtk_tree_view_column_set_expand(column, FALSE);
gtk_tree_view_append_column(theTreeView, column);
sprintf(caption, "Translation");
renderer = gtk_cell_renderer_text_new();
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
g_object_set(renderer, "editable", TRUE, NULL);
g_signal_connect(G_OBJECT (renderer), "edited",
G_CALLBACK (on_translation_edited_cb),
NULL);
translationColumn = gtk_tree_view_column_new_with_attributes(caption,
renderer,
"text", COLUMN_TRANSLATION,
NULL);
gtk_tree_view_column_set_clickable(translationColumn, TRUE);
g_signal_connect(G_OBJECT (translationColumn), "clicked",
G_CALLBACK (on_sort_translation_clicked_cb),
NULL);
gtk_tree_view_column_set_expand(translationColumn, TRUE);
gtk_tree_view_append_column(theTreeView, translationColumn);
gtk_tree_view_set_search_equal_func(theTreeView, searchEqualFunc_cb, NULL, NULL);
gtk_tree_view_set_search_entry(theTreeView, theSearchEntry);
}
void SludgeTranslationEditor::on_tree_selection_changed(GtkTreeSelection *theSelection)
{
GtkTreeIter iter;
GtkTreeModel *model;
gchar *tx;
if (gtk_tree_selection_get_selected(theSelection, &model, &iter)) {
gtk_tree_model_get(model, &iter, COLUMN_ORIGINAL, &tx, -1);
gtk_text_buffer_set_text(theOriginalTextBuffer, tx?tx:"", -1);
g_free(tx);
tx = NULL;
gtk_tree_model_get(model, &iter, COLUMN_TRANSLATION, &tx, -1);
gtk_text_buffer_set_text(theTranslationTextBuffer, tx?tx:"", -1);
g_free(tx);
} else {
gtk_text_buffer_set_text(theOriginalTextBuffer, "", 0);
gtk_text_buffer_set_text(theTranslationTextBuffer, "", 0);
}
}
void SludgeTranslationEditor::on_column_changed(int column, GtkCellRenderer *theCell_renderer, gchar *thePath, gchar *theNewText)
{
GtkTreePath *sortedPath, *filterPath, *listStorePath;
GtkTreeIter iter;
gchar *indexStr;
int index;
sortedPath = gtk_tree_path_new_from_string(thePath);
filterPath = gtk_tree_model_sort_convert_path_to_child_path(GTK_TREE_MODEL_SORT(sortModel), sortedPath);
listStorePath = gtk_tree_model_filter_convert_path_to_child_path(GTK_TREE_MODEL_FILTER(filterModel), filterPath);
gtk_tree_model_get_iter(GTK_TREE_MODEL(listStore), &iter, listStorePath);
indexStr = gtk_tree_path_to_string(listStorePath);
index = atoi(indexStr);
g_free(indexStr);
struct transLine * line = firstTransLine;
for (int j = 0; j < index; j++) {
line = line->next;
}
switch (column) {
case COLUMN_TRANSLATE:
{
if (gtk_cell_renderer_toggle_get_active(GTK_CELL_RENDERER_TOGGLE(theCell_renderer))) {
if (line->transTo) {
if (!askAQuestion("Delete translation?",
"You disabled translation of a string that is already translated. Do you want to delete the existing translation?")) {
return;
}
deleteString(line->transTo);
line->transTo = NULL;
gtk_list_store_set(listStore, &iter, COLUMN_TRANSLATION, "", -1);
}
line->type = TYPE_NONE;
} else {
if (line->transTo)
line->type = TYPE_TRANS;
else
line->type = TYPE_NEW;
}
setFileChanged();
gtk_list_store_set(listStore, &iter, COLUMN_TRANSLATE, line?line->type != TYPE_NONE:FALSE, -1);
break;
}
case COLUMN_TRANSLATION:
{
if (line->type == TYPE_NONE) {
if (!strlen(theNewText) || !askAQuestion("Enable translation?",
"You entered a translation for a string that is not supposed to be translated. Do you want to enable translation for this string?")) {
return;
} else {
gtk_list_store_set(listStore, &iter, COLUMN_TRANSLATE, TRUE, -1);
}
}
if (line->transTo) {
if (! strcmp(line->transTo, theNewText)) {
return;
} else {
setFileChanged();
}
deleteString(line->transTo);
line->transTo = NULL;
} else if (! strlen(theNewText)) {
return;
} else {
setFileChanged();
}
line->transTo = copyString(theNewText);
if (!strlen(line->transTo)) {
if (line->type != TYPE_NONE)
line->type = TYPE_NEW;
deleteString(line->transTo);
line->transTo = NULL;
} else {
line->type = TYPE_TRANS;
}
gtk_list_store_set(listStore, &iter, COLUMN_TRANSLATION, theNewText, -1);
on_tree_selection_changed(selection);
break;
}
default:
break;
}
int type = gtk_combo_box_get_active(comboBox);
if ( (type == 0) ||
(type == 1 && line->type == TYPE_NEW) ||
(type == 2 && line->type == TYPE_TRANS) ||
(type == 3 && line->type == TYPE_NONE) )
{
gtk_list_store_set(listStore, &iter, COLUMN_VISIBLE, TRUE, -1);
} else {
gtk_list_store_set(listStore, &iter, COLUMN_VISIBLE, FALSE, -1);
}
}
void SludgeTranslationEditor::on_sort_clicked(GtkTreeViewColumn *theTreeViewColumn, int sortColumn)
{
GtkTreeViewColumn *theOtherColumn;
if (sortColumn == COLUMN_ORIGINAL) {
theOtherColumn = translationColumn;
} else {
theOtherColumn = originalColumn;
}
if (gtk_tree_view_column_get_sort_indicator(theOtherColumn)) {
gtk_tree_view_column_set_sort_indicator(theOtherColumn, FALSE);
}
if (!gtk_tree_view_column_get_sort_indicator(theTreeViewColumn)) {
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (sortModel),
sortColumn, GTK_SORT_ASCENDING);
} else {
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (sortModel),
COLUMN_ID, GTK_SORT_ASCENDING);
}
gtk_tree_view_column_set_sort_indicator(theTreeViewColumn,
!gtk_tree_view_column_get_sort_indicator(theTreeViewColumn));
// Resize, because sort indicator may change width of column:
GtkWidget *treeView = gtk_tree_view_column_get_tree_view(theTreeViewColumn);
gtk_container_resize_children(GTK_CONTAINER(treeView));
}
void SludgeTranslationEditor::on_load_strings_clicked()
{
GtkWidget *dialog;
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new("Select a SLUDGE Project",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, "SLUDGE Project Files (*.slp)");
gtk_file_filter_add_pattern(filter, "*.[sS][lL][pP]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER (dialog), FALSE);
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
flipBackslashes(&filename);
if (updateFromProject (filename, &firstTransLine)) {
listChanged();
}
setFolderFromFilename(filename);
g_free(filename);
}
gtk_widget_destroy(dialog);
}
gboolean SludgeTranslationEditor::searchEqualFunc(GtkTreeModel *model, const gchar *key, GtkTreeIter *iter)
{
gboolean retval = TRUE;
char *escaped_key, *pattern, *original, *translation;
GRegex *regex;
GError *error = NULL;
gtk_tree_model_get(model, iter, COLUMN_ORIGINAL, &original, COLUMN_TRANSLATION, &translation, -1);
escaped_key = g_regex_escape_string(key, strlen(key));
pattern = new char[strlen(escaped_key) + 5];
sprintf(pattern, ".*%s.*", escaped_key);
g_free(escaped_key);
regex = g_regex_new (pattern, G_REGEX_CASELESS, G_REGEX_MATCH_ANCHORED, &error);
if (regex == NULL) fprintf(stderr, "%s\n", error->message);
if (original) {
if (strlen(original)) {
if (g_regex_match (regex, original, G_REGEX_MATCH_ANCHORED, NULL))
{
retval = FALSE;
}
}
}
if (retval && translation) {
if (strlen(translation)) {
if (g_regex_match (regex, translation, G_REGEX_MATCH_ANCHORED, NULL))
{
retval = FALSE;
}
}
}
g_free(original);
g_free(translation);
g_regex_unref(regex);
delete pattern;
return retval;
}
sludge-2.2/GTK_Dev_Kit/ProjectManager.rc 0000644 0001750 0001750 00000001575 11704133104 015044 0000000 0000000 #include "../source/CommonCode/version.h"
ID ICON "../images/ProjIcon/ProjIcon.ico"
1 VERSIONINFO
FILEVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "Comments", "For more info on SLUDGE, see http://opensludge.sourceforge.net"
VALUE "CompanyName", "SLUDGE Developers"
VALUE "FileDescription", "SLUDGE Project Manager"
VALUE "FileVersion", TEXT_VERSION
VALUE "InternalName", "sludge-projectmanager"
VALUE "LegalCopyright", "(C) 2000 - 2012 Hungry Software and contributors"
VALUE "OriginalFilename", "sludge-projectmanager.exe"
VALUE "ProductName", "SLUDGE Dev Kit"
VALUE "ProductVersion", TEXT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
sludge-2.2/GTK_Dev_Kit/ProjectManagerMain.cpp 0000644 0001750 0001750 00000017205 11700301464 016026 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* ProjectManagerMain.cpp - Part of the SLUDGE Project Manager (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include "ProjectManagerMain.h"
#include "SludgeProjectManager.h"
#include "Common.h"
SludgeProjectManager *projectManager;
#ifdef __cplusplus
extern "C" {
#endif
// SludgeApplication callbacks:
G_MODULE_EXPORT gboolean on_window1_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return projectManager->on_window1_delete_event();
}
G_MODULE_EXPORT void on_new(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_new();
}
G_MODULE_EXPORT void on_open(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_open();
}
G_MODULE_EXPORT void on_save(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_save();
}
G_MODULE_EXPORT void on_save_as(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_save_as();
}
G_MODULE_EXPORT void
on_about(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_about();
}
// SludgeProjectManager callbacks:
G_MODULE_EXPORT void on_files_treeview_realize(GtkTreeView *theTreeView, gpointer theUser_data)
{
projectManager->on_treeview_realize(theTreeView, FILE_TREEVIEW);
}
G_MODULE_EXPORT void on_resources_treeview_realize(GtkTreeView *theTreeView, gpointer theUser_data)
{
projectManager->on_treeview_realize(theTreeView, RESOURCE_TREEVIEW);
}
G_MODULE_EXPORT void on_errors_treeview_realize(GtkTreeView *theTreeView, gpointer theUser_data)
{
projectManager->on_treeview_realize(theTreeView, ERROR_TREEVIEW);
}
G_MODULE_EXPORT void
on_files_tree_selection_changed_cb(GtkTreeSelection *theSelection, gpointer theUser_data)
{
projectManager->on_files_tree_selection_changed(theSelection);
}
G_MODULE_EXPORT void
on_files_treeview_row_activated(GtkTreeView *theTreeView, GtkTreePath *thePath, GtkTreeViewColumn *theColumn, gpointer theUser_data)
{
projectManager->on_treeview_row_activated(theTreeView, thePath, theColumn, FILE_TREEVIEW);
}
G_MODULE_EXPORT void
on_resources_treeview_row_activated(GtkTreeView *theTreeView, GtkTreePath *thePath, GtkTreeViewColumn *theColumn, gpointer theUser_data)
{
projectManager->on_treeview_row_activated(theTreeView, thePath, theColumn, RESOURCE_TREEVIEW);
}
G_MODULE_EXPORT void
on_errors_treeview_row_activated(GtkTreeView *theTreeView, GtkTreePath *thePath, GtkTreeViewColumn *theColumn, gpointer theUser_data)
{
projectManager->on_treeview_row_activated(theTreeView, thePath, theColumn, ERROR_TREEVIEW);
}
G_MODULE_EXPORT void on_add_file_clicked(GtkButton *theButton, gpointer theUser_data)
{
projectManager->on_add_file_clicked();
}
G_MODULE_EXPORT void on_remove_file_clicked(GtkButton *theButton, gpointer theUser_data)
{
projectManager->on_remove_file_clicked();
}
G_MODULE_EXPORT void on_compile(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_compile();
}
G_MODULE_EXPORT void on_comp_okbutton_clicked(GtkButton *theButton, gpointer theUser_data)
{
projectManager->on_comp_okbutton_clicked(theButton);
}
G_MODULE_EXPORT void on_comp_gamebutton_clicked(GtkButton *theButton, gpointer theUser_data)
{
projectManager->on_comp_gamebutton_clicked();
}
G_MODULE_EXPORT void on_project_settings(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_project_settings();
}
G_MODULE_EXPORT void on_preferences(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_preferences();
}
G_MODULE_EXPORT void on_floormaker_activate(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_program_activate(FLOORMAKER);
}
G_MODULE_EXPORT void on_spritebankeditor_activate(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_program_activate(SPRITEBANKEDITOR);
}
G_MODULE_EXPORT void on_zbuffermaker_activate(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_program_activate(ZBUFFERMAKER);
}
G_MODULE_EXPORT void on_translationeditor_activate(GtkMenuItem *theItem, gpointer theUser_data)
{
projectManager->on_program_activate(TRANSLATIONEDITOR);
}
G_MODULE_EXPORT void *compile_hook(gpointer nothing)
{
projectManager->compile();
}
G_MODULE_EXPORT gboolean update_compile_window_hook(gpointer nothing)
{
projectManager->update_compile_window();
return FALSE;
}
void receiveCompilerInfo(compilerInfo *info)
{
g_async_queue_push(projectManager->compilerInfoQueue, info);
g_idle_add(update_compile_window_hook, NULL);
}
G_MODULE_EXPORT gboolean on_project_settings_dialog_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return gtk_widget_hide_on_delete(theWidget);
}
G_MODULE_EXPORT gboolean on_preferences_dialog_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return gtk_widget_hide_on_delete(theWidget);
}
G_MODULE_EXPORT gboolean on_compiler_dialog_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return gtk_widget_hide_on_delete(theWidget);
}
#ifdef __cplusplus
}
#endif
void printCmdlineUsage() {
fprintf(stdout, "SLUDGE Project Manager, usage: sludge-projectmanager \n");
}
bool parseCmdlineParameters(int argc, char *argv[]) {
int retval = true;
while (1)
{
static struct option long_options[] =
{
{"help", no_argument, 0, 'h' },
{0,0,0,0} /* This is a filler for -1 */
};
int option_index = 0;
int c = getopt_long(argc, argv, "h", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h':
default:
retval = false;
break;
}
}
return retval;
}
/*
* The main function.
*/
int
main(int argc, char *argv[])
{
char *openThisFile = argv[argc - 1];
if (! parseCmdlineParameters(argc, argv) ) {
printCmdlineUsage();
return 0;
}
if (argc < 2) {
openThisFile = NULL;
} else if (! fileExists(openThisFile) ) {
errorBox("Project file not found!", joinTwoStrings("File not found:\n", openThisFile));
printCmdlineUsage();
return -1;
}
// On Windows, change to the program directory to
// make sure the necessary resource files are found:
winChangeToProgramDir(argv[0]);
if (!g_thread_supported ()){ g_thread_init (NULL); }
gdk_threads_init ();
gdk_threads_enter ();
/*
* Init GTK+.
*/
gtk_init(&argc, &argv);
projectManager = new SludgeProjectManager();
/*
* Get the window manager to connect any assigned signals in the loaded Glade file to our coded functions.
*/
gtk_builder_connect_signals(projectManager->theXml, NULL);
/*
* Show the window.
*/
gtk_widget_show(projectManager->theWindow);
if (openThisFile != NULL) {
projectManager->open(openThisFile);
}
// Run the window manager loop.
if (projectManager->initSuccess)
gtk_main ();
delete projectManager;
gdk_threads_leave ();
return 0;
}
sludge-2.2/GTK_Dev_Kit/ZBufferMaker.rc 0000644 0001750 0001750 00000001562 11704133104 014462 0000000 0000000 #include "../source/CommonCode/version.h"
ID ICON "../images/zIcon/zIcon.ico"
1 VERSIONINFO
FILEVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "Comments", "For more info on SLUDGE, see http://opensludge.sourceforge.net"
VALUE "CompanyName", "SLUDGE Developers"
VALUE "FileDescription", "SLUDGE Z-Buffer Maker"
VALUE "FileVersion", TEXT_VERSION
VALUE "InternalName", "sludge-zbuffermaker"
VALUE "LegalCopyright", "(C) 2000 - 2012 Hungry Software and contributors"
VALUE "OriginalFilename", "sludge-zbuffermaker.exe"
VALUE "ProductName", "SLUDGE Dev Kit"
VALUE "ProductVersion", TEXT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
sludge-2.2/GTK_Dev_Kit/SludgeFloorMaker.h 0000644 0001750 0001750 00000004440 11700301465 015170 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeFloorMaker.h - Part of the SLUDGE Floor Maker (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "SludgeGLApplication.h"
#include "sprites.h"
class SludgeFloorMaker : public SludgeGLApplication {
private:
float r,g,b;
int lit, litX, litY;
int selection, selx1, sely1, selx2, sely2;
int mouseLoc1x, mouseLoc1y;
struct spriteBank backdrop;
struct polyList * firstPoly;
int mode;
private:
// Concrete methods for SludgeApplication:
virtual gboolean init(gboolean calledFromConstructor);
virtual const char * getWindowTitle();
virtual const char * getFilterName();
virtual const char * getFilterPattern();
virtual const char * getUntitledFilename();
virtual gboolean saveFile(char *filename);
virtual gboolean loadFile(char *filename);
virtual void postNew();
virtual void postOpen();
// Concrete methods for SludgeGLApplication:
virtual void button1Press(int local_pointx, int local_pointy);
virtual void button1Release(int local_pointx, int local_pointy);
virtual void button1Motion(int local_pointx, int local_pointy);
virtual void drawingareaLeft();
virtual void prepareOpenGL();
virtual void drawRect();
struct polyList * getFloor();
void setFloor(struct polyList * floor);
public:
SludgeFloorMaker();
~SludgeFloorMaker();
// Callbacks:
void on_filechooserbutton_realize(GtkFileChooser *theChooser);
void on_filechooserbutton_file_set(GtkFileChooser *theChooser);
void on_colorbutton_realize(GtkColorButton *theButton);
void on_colorbutton_color_set(GtkColorButton *theButton);
void on_mode_changed(int buttonClicked);
};
sludge-2.2/GTK_Dev_Kit/SpriteBankEditorMain.cpp 0000644 0001750 0001750 00000021172 11700301465 016335 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SpriteBankEditorMain.cpp - Part of the SLUDGE Sprite Bank Editor (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include "SludgeSpriteBankEditor.h"
#include "Common.h"
SludgeSpriteBankEditor *spriteBankEditor;
#ifdef __cplusplus
extern "C" {
#endif
// SludgeApplication callbacks:
G_MODULE_EXPORT gboolean on_window1_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_window1_delete_event();
}
G_MODULE_EXPORT void on_new(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_new();
}
G_MODULE_EXPORT void on_open(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_open();
}
G_MODULE_EXPORT void on_save(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_save();
}
G_MODULE_EXPORT void on_save_as(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_save_as();
}
G_MODULE_EXPORT void
on_about(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_about();
}
// SludgeGLApplication callbacks:
G_MODULE_EXPORT void on_drawingarea1_realize(GtkWidget *theWidget, gpointer theUser_data)
{
spriteBankEditor->on_drawingarea1_realize(theWidget);
}
G_MODULE_EXPORT gboolean on_drawingarea1_configure_event(GtkWidget *theWidget, GdkEventConfigure *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_configure_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean on_drawingarea1_expose_event(GtkWidget *theWidget, GdkEventExpose *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_expose_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean render_timer_event(gpointer theUser_data)
{
return spriteBankEditor->render_timer_event(theUser_data);
}
G_MODULE_EXPORT gboolean on_drawingarea1_scroll_event(GtkWidget *theWidget, GdkEventScroll *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_scroll_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean on_drawingarea1_button_press_event(GtkWidget *theWidget, GdkEventButton *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_button_press_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean on_drawingarea1_button_release_event(GtkWidget *theWidget, GdkEventButton *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_button_release_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean on_drawingarea1_motion_notify_event(GtkWidget *theWidget, GdkEventMotion *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_motion_notify_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean on_drawingarea1_leave_notify_event(GtkWidget *theWidget, GdkEventAny *theEvent, gpointer theUser_data)
{
return spriteBankEditor->on_drawingarea1_leave_notify_event(theWidget, theEvent);
}
G_MODULE_EXPORT void on_zoom_100_realize(GtkToolButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_zoom_100_realize(theButton);
}
G_MODULE_EXPORT void on_zoom_fit_realize(GtkToolButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_zoom_fit_realize(theButton);
}
G_MODULE_EXPORT void on_zoom_100_clicked(GtkToolButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_zoom_100_clicked();
}
G_MODULE_EXPORT void on_zoom_fit_clicked(GtkToolButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_zoom_fit_clicked();
}
// SludgeSpriteBankEditor callbacks:
G_MODULE_EXPORT void on_show_box_toggled(GtkToggleButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_show_box_toggled(theButton);
}
G_MODULE_EXPORT void on_x_spinbutton_value_changed(GtkSpinButton *theSpinButton, gpointer theUser_data)
{
spriteBankEditor->on_x_spinbutton_value_changed();
}
G_MODULE_EXPORT void on_y_spinbutton_value_changed(GtkSpinButton *theSpinButton, gpointer theUser_data)
{
spriteBankEditor->on_y_spinbutton_value_changed();
}
G_MODULE_EXPORT void on_centre_hotspot_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_centre_hotspot_clicked();
}
G_MODULE_EXPORT void on_base_hotspot_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_base_hotspot_clicked();
}
G_MODULE_EXPORT void on_multi_hotspot_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_multi_hotspot_clicked();
}
G_MODULE_EXPORT void on_mode_pal_open_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_mode_pal_clicked(0);
}
G_MODULE_EXPORT void on_mode_pal_closed_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_mode_pal_clicked(1);
}
G_MODULE_EXPORT void on_mode_pal_none_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_mode_pal_clicked(2);
}
G_MODULE_EXPORT void on_insert_sprite_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_insert_sprite_clicked(FALSE, TRUE);
}
G_MODULE_EXPORT void on_delete_sprite_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_delete_sprite_clicked();
}
G_MODULE_EXPORT void on_replace_sprite_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_insert_sprite_clicked(FALSE, FALSE);
}
G_MODULE_EXPORT void on_export_sprite_clicked(GtkButton *theButton, gpointer theUser_data)
{
spriteBankEditor->on_export_sprite_clicked();
}
G_MODULE_EXPORT void on_hscale_value_changed(GtkHScale *theScale, gpointer theUser_data)
{
spriteBankEditor->on_hscale_value_changed();
}
G_MODULE_EXPORT void on_fontify(GtkMenuItem *theItem, gpointer theUser_data)
{
spriteBankEditor->on_fontify();
}
G_MODULE_EXPORT gboolean on_fontify_dialog_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return gtk_widget_hide_on_delete(theWidget);
}
#ifdef __cplusplus
}
#endif
void printCmdlineUsage() {
fprintf(stdout, "SLUDGE Sprite Bank Editor, usage: sludge-spritebankeditor \n");
}
bool parseCmdlineParameters(int argc, char *argv[]) {
int retval = true;
while (1)
{
static struct option long_options[] =
{
{"help", no_argument, 0, 'h' },
{0,0,0,0} /* This is a filler for -1 */
};
int option_index = 0;
int c = getopt_long(argc, argv, "h", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h':
default:
retval = false;
break;
}
}
return retval;
}
/*
* The main function.
*/
int
main(int argc, char *argv[])
{
char *openThisFile = argv[argc - 1];
if (! parseCmdlineParameters(argc, argv) ) {
printCmdlineUsage();
return 0;
}
if (argc < 2) {
openThisFile = NULL;
} else if (! fileExists(openThisFile) ) {
fprintf(stderr, "Sprite bank file not found.\n");
printCmdlineUsage();
return -1;
}
// On Windows, change to the program directory to
// make sure the necessary resource files are found:
winChangeToProgramDir(argv[0]);
if (!g_thread_supported()){ g_thread_init(NULL); }
gdk_threads_init();
gdk_threads_enter();
/*
* Init GTK+ and GtkGLExt.
*/
gtk_init(&argc, &argv);
gtk_gl_init(&argc, &argv);
spriteBankEditor = new SludgeSpriteBankEditor();
/*
* Get the window manager to connect any assigned signals in the loaded Glade file to our coded functions.
*/
gtk_builder_connect_signals(spriteBankEditor->theXml, NULL);
/*
* Show the window.
*/
gtk_widget_show(spriteBankEditor->theWindow);
// Start the render timer.
g_timeout_add(10000 / 60, render_timer_event, spriteBankEditor->theDrawingarea);
if (openThisFile != NULL) {
spriteBankEditor->open(openThisFile);
}
// Run the window manager loop.
if (spriteBankEditor->initSuccess)
gtk_main();
delete spriteBankEditor;
gdk_threads_leave();
return 0;
}
sludge-2.2/GTK_Dev_Kit/SludgeTranslationEditor.h 0000644 0001750 0001750 00000004727 11700301634 016602 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeTranslationEditor.h - Part of the SLUDGE Translation Editor (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "SludgeApplication.h"
enum {
COLUMN_ORIGINAL,
COLUMN_TRANSLATE,
COLUMN_TRANSLATION,
COLUMN_ID,
COLUMN_VISIBLE,
N_COLUMNS
};
class SludgeTranslationEditor : public SludgeApplication {
private:
struct transLine * firstTransLine;
char * langName;
gboolean badLangName;
GtkComboBox *comboBox;
GtkListStore *listStore;
GtkTreeModel *filterModel, *sortModel;
GtkTreeSelection *selection;
GtkTreeViewColumn *originalColumn, *translationColumn;
GtkAdjustment *theIdAdjustment;
GtkEntry *theLanguageEntry;
GtkEntry *theSearchEntry;
GtkTextBuffer *theOriginalTextBuffer, *theTranslationTextBuffer;
private:
// Concrete methods for SludgeApplication:
virtual gboolean init(gboolean calledFromConstructor);
virtual const char * getWindowTitle();
virtual const char * getFilterName();
virtual const char * getFilterPattern();
virtual const char * getUntitledFilename();
virtual gboolean saveFile(char *filename);
virtual gboolean loadFile(char *filename);
virtual void postNew();
virtual void postOpen();
void listChanged();
public:
SludgeTranslationEditor();
// Callbacks:
void on_combobox_realize(GtkComboBox *theComboBox);
void on_combobox_changed(GtkComboBox *theComboBox);
void on_treeview_realize(GtkTreeView *theTreeView);
void on_tree_selection_changed(GtkTreeSelection *theSelection);
void on_column_changed(int column, GtkCellRenderer *theCell_renderer, gchar *thePath, gchar *theNewText);
void on_sort_clicked(GtkTreeViewColumn *theTreeViewColumn, int sortColumn);
void on_load_strings_clicked();
gboolean searchEqualFunc(GtkTreeModel *model, const gchar *key, GtkTreeIter *iter);
};
sludge-2.2/GTK_Dev_Kit/Common.cpp 0000644 0001750 0001750 00000012265 11700301465 013552 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Common.cpp - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include "Common.h"
#include "interface.h"
gint message_dialog( GtkMessageType type, const gchar *title, const gchar *message);
bool askAQuestion (const char * head, const char * msg)
{
gint response;
response = message_dialog(GTK_MESSAGE_QUESTION, head, msg);
if (response == GTK_RESPONSE_YES) return true;
else return false;
}
bool errorBox (const char * head, const char * msg)
{
message_dialog(GTK_MESSAGE_ERROR, head, msg);
return false;
}
gint
message_dialog(GtkMessageType type, const gchar *title, const gchar *message)
{
GtkWidget *dialog;
gint response;
GtkButtonsType buttons;
if (type == GTK_MESSAGE_QUESTION) buttons = GTK_BUTTONS_YES_NO;
else buttons = GTK_BUTTONS_OK;
dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
type,
buttons,
"%s", message);
gtk_window_set_title(GTK_WINDOW(dialog), title);
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return response;
}
void setFileChooserFilters(GtkFileChooser *theFileChooser, gboolean png, gboolean tga)
{
GtkFileFilter *pngtgafilter, *pngfilter, *tgafilter;
if (png && tga) {
pngtgafilter = gtk_file_filter_new();
gtk_file_filter_set_name(pngtgafilter, "PNG/TGA images");
gtk_file_filter_add_mime_type(pngtgafilter, "image/png");
gtk_file_filter_add_mime_type(pngtgafilter, "image/x-tga");
gtk_file_filter_add_pattern(pngtgafilter, "*.[tT][gG][aA]");
gtk_file_chooser_add_filter(theFileChooser, pngtgafilter);
}
if (png) {
pngfilter = gtk_file_filter_new();
gtk_file_filter_set_name(pngfilter, "PNG images");
gtk_file_filter_add_mime_type(pngfilter, "image/png");
gtk_file_chooser_add_filter(theFileChooser, pngfilter);
}
if (tga) {
tgafilter = gtk_file_filter_new();
gtk_file_filter_set_name(tgafilter, "TGA images");
gtk_file_filter_add_mime_type(tgafilter, "image/x-tga");
gtk_file_filter_add_pattern(tgafilter, "*.[tT][gG][aA]");
gtk_file_chooser_add_filter(theFileChooser, tgafilter);
}
if (png && tga) {
gtk_file_chooser_set_filter(theFileChooser, pngtgafilter);
} else if (png) {
gtk_file_chooser_set_filter(theFileChooser, pngfilter);
} else if (tga) {
gtk_file_chooser_set_filter(theFileChooser, tgafilter);
}
}
const char * getTempDir ()
{
return g_get_user_cache_dir();
}
char * joinTwoStrings (const char * a, const char * b) {
char * nS = new char[strlen (a) + strlen (b) + 1];
sprintf (nS, "%s%s", a, b);
return nS;
}
bool fileExists(char * file) {
FILE * tester;
bool retval = false;
tester = fopen (file, "rb");
if (tester) {
retval = true;
fclose (tester);
}
return retval;
}
void flipBackslashes(char **string)
{
#ifdef __WIN32
for (int i = 0; (*string)[i] != 0; i++)
{
if ((*string)[i] == '\\')
(*string)[i] = '/';
}
#endif
}
void winChangeToProgramDir(const char *programFullPath)
{
#ifdef __WIN32
char programPath[1000];
int lastSlash = 0;
sprintf(programPath, "%s", programFullPath);
for (int j = 0; programPath[j] != 0; j++) {
if (programPath[j] == '\\') {
programPath[j] = '/';
lastSlash = j;
}
}
programPath[lastSlash + 1] = NULL;
g_chdir(programPath);
#endif
}
void replaceInvalidCharacters(char *string, int *retval)
{
const gchar *end;
if (!g_utf8_validate(string, -1, &end)) {
for (int i = 0; string[i] != 0; i++) {
if (string[i] == end[0])
string[i] = '_';
}
replaceInvalidCharacters(string, retval);
*retval = 0;
} else {
return;
}
}
int sh_cmd (gchar * path, const gchar * cmd, gchar * args)
{
char *quoted_args;
char cmd_line[256];
char **argv;
int argp;
int rc = 0;
if (cmd == NULL)
return FALSE;
if (cmd[0] == '\0')
return FALSE;
if (path != NULL)
g_chdir (path);
if (args == NULL) {
snprintf (cmd_line, sizeof (cmd_line), "%s", cmd);
} else {
#ifdef __WIN32
for (int i = 0; args[i] != 0; i++)
{
if (args[i] == '/')
args[i] = '\\';
}
#endif
quoted_args = g_shell_quote (args);
snprintf (cmd_line, sizeof (cmd_line), "%s %s", cmd, quoted_args);
g_free(quoted_args);
}
rc = g_shell_parse_argv (cmd_line, &argp, &argv, NULL);
if (!rc)
{
g_strfreev (argv);
return rc;
}
rc = g_spawn_async (path, argv, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL);
g_strfreev (argv);
return rc;
}
sludge-2.2/GTK_Dev_Kit/SludgeGLApplication.h 0000644 0001750 0001750 00000006161 11700301465 015617 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeGLApplication.h - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "SludgeApplication.h"
class SludgeGLApplication : public SludgeApplication {
private:
int mouseLoc2x, mouseLoc2y;
gboolean haveStatusbar;
GdkPixmap *pixmap;
GdkGLPixmap *glpixmap;
GdkGLContext *context;
GdkGLDrawable *glDrawable;
GdkGLContext *glContext;
GtkToolButton *zoom100Button, *zoomFitButton;
GtkWidget *statusbarWidget;
GtkLabel *cursorxLabel, *cursoryLabel, *picwLabel, *pichLabel, *zmulLabel;
GMutex * theRender_mutex;
protected:
int x, y, w, h;
float z, zmul;
int picWidth, picHeight;
gboolean awaitButton1Release, awaitButton2Release;
public:
GtkWidget *theDrawingarea;
private:
virtual void button1Press(int local_pointx, int local_pointy) = 0;
virtual void button1Release(int local_pointx, int local_pointy) = 0;
virtual void button1Motion(int local_pointx, int local_pointy) = 0;
virtual void drawingareaLeft() = 0;
virtual void prepareOpenGL() = 0;
virtual void drawRect() = 0;
protected:
void setZ(float newZ);
void activateZoomButtons(int picwidth, int picheight);
void deactivateZoomButtons();
void showStatusbar(int picwidth, int picheight);
void refreshStatusbarCursor(int local_pointx, int local_pointy);
void refreshStatusbarZmul();
void hideStatusbar();
void reshape();
void setCoords();
public:
SludgeGLApplication(const char * gladeFileName, const char * iconName, const char * configFile);
~SludgeGLApplication();
// Callbacks:
void on_drawingarea1_realize(GtkWidget *theWidget);
gboolean on_drawingarea1_configure_event(GtkWidget *theWidget, GdkEventConfigure *theEvent);
gboolean on_drawingarea1_expose_event(GtkWidget *theWidget, GdkEventExpose *theEvent);
gboolean render_timer_event(gpointer theUser_data);
gboolean on_drawingarea1_scroll_event(GtkWidget *theWidget, GdkEventScroll *theEvent);
gboolean on_drawingarea1_button_press_event(GtkWidget *theWidget, GdkEventButton *theEvent);
gboolean on_drawingarea1_button_release_event(GtkWidget *theWidget, GdkEventButton *theEvent);
gboolean on_drawingarea1_motion_notify_event(GtkWidget *theWidget, GdkEventMotion *theEvent);
gboolean on_drawingarea1_leave_notify_event(GtkWidget *theWidget, GdkEventAny *theEvent);
void on_zoom_100_realize(GtkToolButton *theButton);
void on_zoom_fit_realize(GtkToolButton *theButton);
void on_zoom_100_clicked();
void on_zoom_fit_clicked();
};
sludge-2.2/GTK_Dev_Kit/CompilerMain.cpp 0000644 0001750 0001750 00000007131 11700301465 014675 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* CompilerMain.cpp
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include "project.hpp"
#include "settings.h"
#include "compiler.hpp"
#include "interface.h"
#include "errorlinktofile.h"
//The functions declared in interface.h:
bool askAQuestion (const char * head, const char * msg)
{
return true;
}
bool errorBox (const char * head, const char * msg)
{
fprintf(stderr, "%s\n%s\n", head, msg);
return false;
}
const char * getTempDir ()
{
return g_get_user_cache_dir();
}
bool fileExists(char * file) {
FILE * tester;
bool retval = false;
tester = fopen (file, "rb");
if (tester) {
retval = true;
fclose (tester);
}
return retval;
}
void receiveCompilerInfo(compilerInfo *info)
{
if (info->newComments) {
if (! errorList) return;
fprintf(stderr, "%s\n", errorList->fullText);
}
}
void printCmdlineUsage() {
fprintf(stdout, "SLUDGE compiler, usage: sludge-compiler [] \n\n");
fprintf(stdout, "Options:\n");
fprintf(stdout, "-k, --keep-slx Keep compressed image files that are generated during compilation.\n");
fprintf(stdout, "-t, --string-file Write a text file of the strings contained in the game.\n");
fprintf(stdout, "-s, --strip-debug-info Strip debug information from the game file.\n");
fprintf(stdout, "-h, --help Print this help message\n\n");
}
bool parseCmdlineParameters(int argc, char *argv[]) {
int retval = true;
programSettings.compilerKillImages = 1;
programSettings.compilerWriteStrings = 0;
programSettings.compilerVerbose = 1;
programSettings.searchSensitive = 0;
while (1)
{
static struct option long_options[] =
{
{"keep-slx", no_argument, 0, 'k' },
{"string-file", no_argument, 0, 't' },
{"silent", no_argument, 0, 's' },
{"help", no_argument, 0, 'h' },
{0,0,0,0} /* This is a filler for -1 */
};
int option_index = 0;
int c = getopt_long (argc, argv, "ktsh", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'k':
programSettings.compilerKillImages = 0;
break;
case 't':
programSettings.compilerWriteStrings = 1;
break;
case 's':
programSettings.compilerVerbose = 0;
break;
case 'h':
default:
retval = false;
break;
}
}
return retval;
}
int main (int argc, char *argv[])
{
char *fileList[1000];
int fileListNum;
if (! parseCmdlineParameters(argc, argv) ) {
printCmdlineUsage();
return 0;
}
if (argc < 2 || ! fileExists(argv[argc - 1]) ) {
fprintf(stderr, "Project file not found.\n");
printCmdlineUsage();
return -1;
}
if (!loadProject (argv[argc - 1], fileList, &fileListNum))
{
fprintf(stderr, "Error loading project.\n");
return -1;
}
fprintf(stderr, "Start compiling...\n");
if (!compileEverything(argv[argc - 1], fileList, &fileListNum, &receiveCompilerInfo))
{
fprintf(stderr, "Error compiling project.\n");
return -1;
}
return 0;
}
sludge-2.2/GTK_Dev_Kit/SludgeApplication.h 0000644 0001750 0001750 00000003710 11700301465 015371 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeApplication.h - Part of the SLUDGE Dev Kit (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
class SludgeApplication {
private:
const char * configfile;
gboolean fileChanged;
protected:
char currentFilename[260], currentShortname[260], currentFolder[260];
public:
GtkWidget *theWindow;
GtkBuilder *theXml;
gboolean initSuccess;
private:
virtual gboolean init(gboolean calledFromConstructor) = 0;
virtual const char * getWindowTitle() = 0;
virtual const char * getFilterName() = 0;
virtual const char * getFilterPattern() = 0;
virtual const char * getUntitledFilename() = 0;
virtual gboolean saveFile(char *filename) = 0;
virtual gboolean loadFile(char *filename) = 0;
virtual void postNew() = 0;
virtual void postOpen() = 0;
void saveToFile();
gboolean reallyClose();
protected:
void setFilename(char* filename);
void setFolderFromFilename(char* filename);
void setFileChanged();
public:
SludgeApplication(const char * gladeFileName, const char * iconName, const char * configFile);
~SludgeApplication();
void open(char* filename);
// Callbacks:
gboolean on_window1_delete_event();
void on_new();
void on_open();
void on_save();
void on_save_as();
void on_about();
};
sludge-2.2/GTK_Dev_Kit/make_resources.sh 0000755 0001750 0001750 00000000630 11700301465 015155 0000000 0000000 #!/bin/sh
i586-mingw32msvc-windres FloorMaker.rc -O coff -o FloorMakerResources.o
i586-mingw32msvc-windres SpriteBankEditor.rc -O coff -o SpriteBankEditorResources.o
i586-mingw32msvc-windres ZBufferMaker.rc -O coff -o ZBufferMakerResources.o
i586-mingw32msvc-windres TranslationEditor.rc -O coff -o TranslationEditorResources.o
i586-mingw32msvc-windres ProjectManager.rc -O coff -o ProjectManagerResources.o
sludge-2.2/GTK_Dev_Kit/ProjectManager.glade 0000644 0001750 0001750 00000166672 11700301465 015531 0000000 0000000
SLUDGE Project Manager
520
580
True
vertical
False
0
True
True
True
12
vertical
12
True
12
True
True
automatic
automatic
in
True
True
0
True
True
automatic
automatic
in
True
True
1
0
True
12
True
True
spread
gtk-add
True
True
True
True
False
False
0
gtk-remove
True
True
True
True
False
False
1
False
0
True
1
False
False
1
True
Project Files
False
True
True
12
automatic
automatic
in
True
True
2
True
Compiler Errors
1
False
1
4000
1
10
4000
1
10
400
1
10
5
Compiling
True
300
normal
False
True
vertical
2
True
6
vertical
6
True
False
0
True
False
1
True
0
2
True
0
3
True
0
4
True
False
5
True
5
2
6
6
True
1
Function count:
True
1
Object count:
1
2
True
1
Global variable count:
2
3
True
1
String count:
3
4
True
1
Resource count:
4
5
True
0
1
2
True
0
1
2
1
2
True
0
1
2
2
3
True
0
1
2
3
4
True
0
1
2
4
5
6
1
True
end
Run Game
True
True
True
False
False
0
gtk-close
True
True
True
True
False
False
1
False
end
0
comp_gamebutton
comp_okbutton
True
compiler_16x16x32.png
5
Project Settings
normal
False
True
vertical
2
True
6
10
2
12
6
True
True
●
1
2
True
True
●
1
2
1
2
True
True
●
1
2
2
3
True
True
●
1
2
3
4
True
True
●
1
2
4
5
True
True
●
1
2
5
6
True
True
●
1
2
6
7
True
1
Save games in subfolder:
right
2
3
GTK_FILL
True
1
Quit message:
right
1
2
GTK_FILL
True
1
Window name:
right
GTK_FILL
True
1
Game language:
right
3
4
GTK_FILL
True
1
Filename:
right
4
5
GTK_FILL
True
1
Custom icon:
right
5
6
GTK_FILL
True
1
Custom logo (310x88):
right
6
7
GTK_FILL
True
1
Window width:
right
7
8
GTK_FILL
True
1
Frame speed (ms/frame):
center
8
9
GTK_FILL
True
True
True
True
●
speed_adjustment
0
True
1
True
2
1
2
8
9
True
True
True
True
●
width_adjustment
0
True
1
Height:
10
1
True
True
●
height_adjustment
2
1
2
7
8
Force silent
True
True
False
True
1
2
9
10
1
True
end
gtk-cancel
True
True
True
True
False
False
0
gtk-ok
True
True
True
True
False
False
1
False
end
0
button1
save_settings
6
Preferences
normal
False
True
vertical
2
True
6
vertical
6
True
True
0
True
vertical
6
Keep compressed images
True
True
False
True
0
Write strings to text file
True
True
False
True
1
Verbose errors (development mode)
True
True
False
True
2
1
0
True
4
2
12
6
True
True
●
1
2
True
True
●
1
2
1
2
True
True
●
1
2
2
3
True
1
Audio Player:
right
2
3
GTK_FILL
True
1
Image Viewer:
right
1
2
GTK_FILL
True
1
Editor:
right
GTK_FILL
True
1
mod/it/xm/s3m Player:
right
3
4
GTK_FILL
True
True
●
1
2
3
4
1
0
True
end
gtk-cancel
True
True
True
True
False
False
0
gtk-ok
True
True
True
True
False
False
1
False
end
1
button2
save_settings1
True
gameIcon_16x16x32.png
True
floorIcon_16x16x32.png
True
spriteIcon_16x16x32.png
True
zIcon_16x16x32.png
True
flags_16x16x32.png
sludge-2.2/GTK_Dev_Kit/SludgeZBufferMaker.cpp 0000644 0001750 0001750 00000017735 11700301465 016020 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeZBufferMaker.cpp - Part of the SLUDGE Z-Buffer Maker (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include "zbuffer.h"
#include "Common.h"
#include "SludgeZBufferMaker.h"
SludgeZBufferMaker::SludgeZBufferMaker()
: SludgeGLApplication(joinTwoStrings(DATADIR, "ZBufferMaker.glade"), "zIcon", "zbuffermaker")
{
if (!initSuccess) return;
theSliderAdjustment = GTK_ADJUSTMENT (gtk_builder_get_object(theXml, "slider_adjustment"));
theYAdjustment = GTK_ADJUSTMENT (gtk_builder_get_object(theXml, "y_adjustment"));
theNumBuffersLabel = GTK_LABEL (gtk_builder_get_object(theXml, "num_buffers_label"));
saveItem = GTK_WIDGET (gtk_builder_get_object(theXml, "save"));
saveAsItem = GTK_WIDGET (gtk_builder_get_object(theXml, "save_as"));
init(TRUE);
setupButtons();
}
// Concrete methods for SludgeApplication:
gboolean SludgeZBufferMaker::init(gboolean calledFromConstructor)
{
currentFilename[0] = 0;
sprintf(currentShortname, "%s", getUntitledFilename());
setBuffer(1);
if (calledFromConstructor) {
backdrop.total=0;
backdrop.type=2;
backdrop.sprites=NULL;
backdrop.myPalette.pal=NULL;
backdrop.myPalette.r=NULL;
backdrop.myPalette.g=NULL;
backdrop.myPalette.b=NULL;
if (!reserveSpritePal(&backdrop.myPalette, 0)) {
return TRUE;
}
}
return FALSE;
}
const char * SludgeZBufferMaker::getWindowTitle()
{
return "SLUDGE Z-Buffer Maker";
}
const char * SludgeZBufferMaker::getFilterName()
{
return "SLUDGE Z-Buffer Files (*.zbu)";
}
const char * SludgeZBufferMaker::getFilterPattern()
{
return "*.[zZ][bB][uU]";
}
const char * SludgeZBufferMaker::getUntitledFilename()
{
return "Untitled Z-Buffer.zbu";
}
gboolean SludgeZBufferMaker::saveFile(char *filename)
{
return saveZBufferFile(filename, &backdrop);
}
gboolean SludgeZBufferMaker::loadFile(char *filename)
{
return loadZBufferFile(filename, &backdrop);
}
void SludgeZBufferMaker::postOpen()
{
gtk_adjustment_set_upper( theSliderAdjustment, backdrop.total-1 );
gtk_adjustment_set_upper( theYAdjustment, -backdrop.sprites[0].height*2 ); // *2 to allow obscuring characters exiting to the bottom
setBuffer(1);
setBufferY(backdrop.sprites[buffer()].special);
char buf[5];
sprintf(buf, "%i", backdrop.total-1);
gtk_label_set_text(theNumBuffersLabel, buf);
activateZoomButtons(backdrop.sprites[0].width, -backdrop.sprites[0].height);
showStatusbar(backdrop.sprites[0].width, -backdrop.sprites[0].height);
on_zoom_fit_clicked();
reshape();
loadZTextures(&backdrop);
render_timer_event(theDrawingarea);
setupButtons();
}
void SludgeZBufferMaker::postNew()
{
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new("Load file to zBuffer",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
setFileChooserFilters(GTK_FILE_CHOOSER (dialog), FALSE, TRUE);
if (currentFolder[0] != 0)
{
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), currentFolder);
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
flipBackslashes(&filename);
if (!loadZBufferFromTGA(filename, &backdrop))
{
errorBox("Error", "Loading TGA file failed.");
} else {
setFolderFromFilename(filename);
setFilename(filename);
int i, lastSlash;
for (i = 0; filename[i] != 0; i++)
{
if (filename[i] == '/')
lastSlash = i;
}
currentShortname[i-lastSlash-4] = 'z';
currentShortname[i-lastSlash-3] = 'b';
currentShortname[i-lastSlash-2] = 'u';
currentFilename[0] = 0;
gtk_window_set_title(GTK_WINDOW(theWindow), getWindowTitle());
setFileChanged();
postOpen();
}
g_free(filename);
}
gtk_widget_destroy(dialog);
setupButtons();
}
// Concrete methods for SludgeGLApplication:
void SludgeZBufferMaker::button1Press(int local_pointx, int local_pointy)
{
awaitButton1Release = TRUE;
button1Motion(local_pointx, local_pointy);
}
void SludgeZBufferMaker::button1Release(int local_pointx, int local_pointy)
{
awaitButton1Release = FALSE;
}
void SludgeZBufferMaker::button1Motion(int local_pointx, int local_pointy)
{
if (!awaitButton1Release) return;
int yy = (local_pointy-y)*zmul;
if ( yy >= 0 && yy <= -backdrop.sprites[0].height*2) {
setBufferY(yy);
}
}
void SludgeZBufferMaker::drawingareaLeft() {}
void SludgeZBufferMaker::prepareOpenGL()
{
if (! backdrop.total) {
addSprite(0, &backdrop);
backdrop.sprites[0].width = 640;
backdrop.sprites[0].height = 480;
} else
loadZTextures(&backdrop);
z = 0.0;
zmul = (1.0+z/20);
setCoords();
}
void SludgeZBufferMaker::drawRect()
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
int i;
int b = buffer();
if (backdrop.total>1)
for (i=1; i< backdrop.total; i++) {
if (i == b) {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else
glColor4f(0.2f, 0.0f, 0.5f, 1.0f);
pasteSprite(&backdrop.sprites[i], &backdrop.myPalette, false);
}
glDisable(GL_TEXTURE_2D);
glColor3f(1.0f, 0.35f, 0.35f);
glBegin(GL_LINE_LOOP);
{
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( backdrop.sprites[0].width, 0.0, 0.0);
glVertex3f( backdrop.sprites[0].width, -backdrop.sprites[0].height, 0.0);
glVertex3f( 0.0, -backdrop.sprites[0].height, 0.0);
}
glEnd();
if (b>0) {
glColor4f(0.0f, 1.0f, 0.0f, 0.7f);
glBegin(GL_LINES);
{
glVertex3f( 0.0, backdrop.sprites[b].special, 0.0);
glVertex3f( backdrop.sprites[0].width, backdrop.sprites[b].special, 0.0);
}
glEnd();
}
}
void SludgeZBufferMaker::setupButtons()
{
if (backdrop.total > 0) {
gtk_widget_set_sensitive(saveItem, TRUE);
gtk_widget_set_sensitive(saveAsItem, TRUE);
} else {
gtk_widget_set_sensitive(saveItem, FALSE);
gtk_widget_set_sensitive(saveAsItem, FALSE);
}
}
struct spriteBank * SludgeZBufferMaker::getBackdrop()
{
return &backdrop;
}
int SludgeZBufferMaker::bufferY()
{
return (int)gtk_adjustment_get_value(theYAdjustment);
}
void SludgeZBufferMaker::setBufferY(int i)
{
gtk_adjustment_set_value(theYAdjustment, (double)i);
}
int SludgeZBufferMaker::buffer()
{
return (int)gtk_adjustment_get_value(theSliderAdjustment);
}
void SludgeZBufferMaker::setBuffer(int i)
{
// Validation shouldn't be done here, but I'm cheating.
if (i < 1) i = 1;
if (i > backdrop.total-1) i = backdrop.total-1;
gtk_adjustment_set_value(theSliderAdjustment, (double)i);
}
// Callbacks:
void SludgeZBufferMaker::on_hscale_value_changed(GtkHScale *theScale)
{
// if (buffer() > 0)
// [bufferYTextField setEnabled:YES];
// else
// [bufferYTextField setEnabled:NO];
setBufferY(backdrop.sprites[buffer()].special);
render_timer_event(theDrawingarea);
}
void SludgeZBufferMaker::on_spinbutton_value_changed(GtkSpinButton *theSpinButton)
{
if (buffer() && bufferY() != backdrop.sprites[buffer()].special) {
backdrop.sprites[buffer()].special = bufferY();
setFileChanged();
}
render_timer_event(theDrawingarea);
}
sludge-2.2/GTK_Dev_Kit/SludgeProjectManager.h 0000644 0001750 0001750 00000007121 11700301465 016027 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* SludgeProjectManager.h - Part of the SLUDGE Project Manager (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include "SludgeApplication.h"
enum whichTreeview {
FILE_TREEVIEW,
RESOURCE_TREEVIEW,
ERROR_TREEVIEW
};
enum whichProgram {
FLOORMAKER,
SPRITEBANKEDITOR,
ZBUFFERMAKER,
TRANSLATIONEDITOR
};
enum whichErrorsListStoreColumn {
ERRORS_COLUMN_FULLTEXT,
ERRORS_COLUMN_HAS_FILENAME,
ERRORS_COLUMN_FILENAME,
ERRORS_COLUMN_OVERVIEW,
ERRORS_N_COLUMNS
};
class SludgeProjectManager : public SludgeApplication {
private:
char workingDir[1000];
char editor[1000], imageViewer[1000], audioPlayer[1000], modPlayer[1000];
int numResources;
char *resourceList[1000];
char *fileList[1000];
int fileListNum;
GtkListStore *filesListStore;
GtkListStore *resourcesListStore;
GtkListStore *errorsListStore;
GtkTreeSelection *filesSelection;
GtkNotebook *notebook;
GtkWidget *saveItem, *saveAsItem, *projectPropertiesItem, *projectCompileItem, *projectRunGameItem;
GtkWidget *addFileButton, *removeFileButton;
GtkDialog *compilerDialog;
GtkProgressBar *compProgress1, *compProgress2;
GtkLabel *compTask, *compFile, *compItem, *compFuncs;
GtkLabel *compObjs, *compGlobs, *compStrings, *compResources;
GtkWidget *runGameButton, *closeCompilerButton;
GtkDialog *projectSettingsDialog;
GtkEntry *prefName, *prefQuit, *prefSave, *prefLanguage, *prefFilename, *prefIcon, *prefLogo;
GtkSpinButton *prefWidth, *prefHeight, *prefSpeed;
GtkToggleButton *prefSilent;
GtkDialog *preferenceDialog;
GtkToggleButton *prefKeepImages, *prefWriteStrings, *prefVerbose;
GtkEntry *prefEditor, *prefImageViewer, *prefAudioPlayer, *prefModPlayer;
public:
GAsyncQueue *compilerInfoQueue;
private:
// Concrete methods for SludgeApplication:
virtual gboolean init(gboolean calledFromConstructor);
virtual const char * getWindowTitle();
virtual const char * getFilterName();
virtual const char * getFilterPattern();
virtual const char * getUntitledFilename();
virtual gboolean saveFile(char *filename);
virtual gboolean loadFile(char *filename);
virtual void postNew();
virtual void postOpen();
void setupButtons();
void listChanged(whichTreeview whichOne);
void readIniFile();
void saveIniFile();
public:
SludgeProjectManager();
~SludgeProjectManager();
void compile();
void update_compile_window();
// Callbacks:
void on_treeview_realize(GtkTreeView *theTreeView, whichTreeview whichOne);
void on_files_tree_selection_changed(GtkTreeSelection *theSelection);
void on_treeview_row_activated(GtkTreeView *theTreeView, GtkTreePath *thePath, GtkTreeViewColumn *theColumn, whichTreeview whichOne);
void on_add_file_clicked();
void on_remove_file_clicked();
void on_compile();
void on_comp_okbutton_clicked(GtkButton *theButton);
void on_comp_gamebutton_clicked();
void on_project_settings();
void on_preferences();
void on_program_activate(whichProgram program);
};
sludge-2.2/GTK_Dev_Kit/FloorMaker.rc 0000644 0001750 0001750 00000001563 11704133104 014201 0000000 0000000 #include "../source/CommonCode/version.h"
ID ICON "../images/floorIcon/floorIcon.ico"
1 VERSIONINFO
FILEVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "Comments", "For more info on SLUDGE, see http://opensludge.sourceforge.net"
VALUE "CompanyName", "SLUDGE Developers"
VALUE "FileDescription", "SLUDGE Floor Maker"
VALUE "FileVersion", TEXT_VERSION
VALUE "InternalName", "sludge-floormaker"
VALUE "LegalCopyright", "(C) 2000 - 2012 Hungry Software and contributors"
VALUE "OriginalFilename", "sludge-floormaker.exe"
VALUE "ProductName", "SLUDGE Dev Kit"
VALUE "ProductVersion", TEXT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
sludge-2.2/GTK_Dev_Kit/FloorMakerMain.cpp 0000644 0001750 0001750 00000016627 11700301465 015176 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* FloorMakerMain.cpp - Part of the SLUDGE Floor Maker (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include "SludgeFloorMaker.h"
#include "Common.h"
SludgeFloorMaker *floorMaker;
#ifdef __cplusplus
extern "C" {
#endif
// SludgeApplication callbacks:
G_MODULE_EXPORT gboolean
on_window1_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return floorMaker->on_window1_delete_event();
}
G_MODULE_EXPORT void
on_new(GtkMenuItem *theItem, gpointer theUser_data)
{
floorMaker->on_new();
}
G_MODULE_EXPORT void
on_open(GtkMenuItem *theItem, gpointer theUser_data)
{
floorMaker->on_open();
}
G_MODULE_EXPORT void
on_save(GtkMenuItem *theItem, gpointer theUser_data)
{
floorMaker->on_save();
}
G_MODULE_EXPORT void
on_save_as(GtkMenuItem *theItem, gpointer theUser_data)
{
floorMaker->on_save_as();
}
G_MODULE_EXPORT void
on_about(GtkMenuItem *theItem, gpointer theUser_data)
{
floorMaker->on_about();
}
// SludgeGLApplication callbacks:
G_MODULE_EXPORT void
on_drawingarea1_realize(GtkWidget *theWidget, gpointer theUser_data)
{
floorMaker->on_drawingarea1_realize(theWidget);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_configure_event(GtkWidget *theWidget, GdkEventConfigure *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_configure_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_expose_event(GtkWidget *theWidget, GdkEventExpose *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_expose_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
render_timer_event(gpointer theUser_data)
{
return floorMaker->render_timer_event(theUser_data);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_scroll_event(GtkWidget *theWidget, GdkEventScroll *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_scroll_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_button_press_event(GtkWidget *theWidget, GdkEventButton *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_button_press_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_button_release_event(GtkWidget *theWidget, GdkEventButton *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_button_release_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_motion_notify_event(GtkWidget *theWidget, GdkEventMotion *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_motion_notify_event(theWidget, theEvent);
}
G_MODULE_EXPORT gboolean
on_drawingarea1_leave_notify_event(GtkWidget *theWidget, GdkEventAny *theEvent, gpointer theUser_data)
{
return floorMaker->on_drawingarea1_leave_notify_event(theWidget, theEvent);
}
G_MODULE_EXPORT void
on_zoom_100_realize(GtkToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_zoom_100_realize(theButton);
}
G_MODULE_EXPORT void
on_zoom_fit_realize(GtkToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_zoom_fit_realize(theButton);
}
G_MODULE_EXPORT void
on_zoom_100_clicked(GtkToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_zoom_100_clicked();
}
G_MODULE_EXPORT void
on_zoom_fit_clicked(GtkToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_zoom_fit_clicked();
}
// SludgeFloorMaker callbacks:
G_MODULE_EXPORT void
on_filechooserbutton_realize(GtkFileChooser *theChooser, gpointer theUser_data)
{
floorMaker->on_filechooserbutton_realize(theChooser);
}
G_MODULE_EXPORT void
on_filechooserbutton_file_set(GtkFileChooser *theChooser, gpointer theUser_data)
{
floorMaker->on_filechooserbutton_file_set(theChooser);
}
G_MODULE_EXPORT void
on_colorbutton_realize(GtkColorButton *theButton, gpointer theUser_data)
{
floorMaker->on_colorbutton_realize(theButton);
}
G_MODULE_EXPORT void
on_colorbutton_color_set(GtkColorButton *theButton, gpointer theUser_data)
{
floorMaker->on_colorbutton_color_set(theButton);
}
G_MODULE_EXPORT void
on_define_borders_toggled(GtkRadioToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_mode_changed(0);
}
G_MODULE_EXPORT void
on_move_vertices_toggled(GtkRadioToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_mode_changed(1);
}
G_MODULE_EXPORT void
on_delete_vertices_toggled(GtkRadioToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_mode_changed(2);
}
G_MODULE_EXPORT void
on_split_line_toggled(GtkRadioToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_mode_changed(4);
}
G_MODULE_EXPORT void
on_split_floor_toggled(GtkRadioToolButton *theButton, gpointer theUser_data)
{
floorMaker->on_mode_changed(5);
}
#ifdef __cplusplus
}
#endif
void printCmdlineUsage() {
fprintf(stdout, "SLUDGE Floor Maker, usage: sludge-floormaker \n");
}
bool parseCmdlineParameters(int argc, char *argv[]) {
int retval = true;
while (1)
{
static struct option long_options[] =
{
{"help", no_argument, 0, 'h' },
{0,0,0,0} /* This is a filler for -1 */
};
int option_index = 0;
int c = getopt_long (argc, argv, "h", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h':
default:
retval = false;
break;
}
}
return retval;
}
/*
* The main function.
*/
int
main(int argc, char *argv[])
{
char *openThisFile = argv[argc - 1];
if (! parseCmdlineParameters(argc, argv) ) {
printCmdlineUsage();
return 0;
}
if (argc < 2) {
openThisFile = NULL;
} else if (! fileExists(openThisFile) ) {
fprintf(stderr, "Floor file not found.\n");
printCmdlineUsage();
return -1;
}
// On Windows, change to the program directory to
// make sure the necessary resource files are found:
winChangeToProgramDir(argv[0]);
if (!g_thread_supported ()){ g_thread_init (NULL); }
gdk_threads_init ();
gdk_threads_enter ();
/*
* Init GTK+ and GtkGLExt.
*/
gtk_init (&argc, &argv);
gtk_gl_init (&argc, &argv);
floorMaker = new SludgeFloorMaker();
/*
* Get the window manager to connect any assigned signals in the loaded Glade file to our coded functions.
*/
gtk_builder_connect_signals (floorMaker->theXml, NULL);
/*
* Show the window.
*/
gtk_widget_show (floorMaker->theWindow);
// Start the render timer.
g_timeout_add (10000 / 60, render_timer_event, floorMaker->theDrawingarea);
if (openThisFile != NULL) {
floorMaker->open(openThisFile);
}
// Run the window manager loop.
if (floorMaker->initSuccess)
gtk_main ();
delete floorMaker;
gdk_threads_leave ();
return 0;
}
sludge-2.2/GTK_Dev_Kit/TranslationEditorMain.cpp 0000644 0001750 0001750 00000013305 11700301465 016570 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* TranslationEditorMain.cpp - Part of the SLUDGE TranslationEditor (GTK+ version)
*
* Copyright (C) 2010 Tobias Hansen
*
* 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 3 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, see .
*/
#include
#include
#include
#include
#include
#define GL_GLEXT_PROTOTYPES
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#include
#include "TranslationEditorMain.h"
#include "SludgeTranslationEditor.h"
#include "Common.h"
SludgeTranslationEditor *translationEditor;
#ifdef __cplusplus
extern "C" {
#endif
// SludgeApplication callbacks:
G_MODULE_EXPORT gboolean on_window1_delete_event(GtkWidget *theWidget, GdkEvent *theEvent, gpointer theUser_data)
{
return translationEditor->on_window1_delete_event();
}
G_MODULE_EXPORT void on_new(GtkMenuItem *theItem, gpointer theUser_data)
{
translationEditor->on_new();
}
G_MODULE_EXPORT void on_open(GtkMenuItem *theItem, gpointer theUser_data)
{
translationEditor->on_open();
}
G_MODULE_EXPORT void on_save(GtkMenuItem *theItem, gpointer theUser_data)
{
translationEditor->on_save();
}
G_MODULE_EXPORT void on_save_as(GtkMenuItem *theItem, gpointer theUser_data)
{
translationEditor->on_save_as();
}
G_MODULE_EXPORT void
on_about(GtkMenuItem *theItem, gpointer theUser_data)
{
translationEditor->on_about();
}
// SludgeTranslationEditor callbacks:
G_MODULE_EXPORT void on_combobox_realize(GtkComboBox *theComboBox, gpointer theUser_data)
{
translationEditor->on_combobox_realize(theComboBox);
}
G_MODULE_EXPORT void on_combobox_changed(GtkComboBox *theComboBox, gpointer theUser_data)
{
translationEditor->on_combobox_changed(theComboBox);
}
G_MODULE_EXPORT void on_treeview_realize(GtkTreeView *theTreeView, gpointer theUser_data)
{
translationEditor->on_treeview_realize(theTreeView);
}
G_MODULE_EXPORT void
on_tree_selection_changed_cb(GtkTreeSelection *theSelection, gpointer theUser_data)
{
translationEditor->on_tree_selection_changed(theSelection);
}
G_MODULE_EXPORT void
on_translate_toggled_cb(GtkCellRendererToggle *theCell_renderer, gchar *thePath, gpointer theUser_data)
{
translationEditor->on_column_changed(COLUMN_TRANSLATE, GTK_CELL_RENDERER(theCell_renderer), thePath, NULL);
}
G_MODULE_EXPORT void
on_translation_edited_cb(GtkCellRendererText *theCell_renderer, gchar *thePath, gchar *theNewText, gpointer theUser_data)
{
translationEditor->on_column_changed(COLUMN_TRANSLATION, GTK_CELL_RENDERER(theCell_renderer), thePath, theNewText);
}
G_MODULE_EXPORT void
on_sort_original_clicked_cb(GtkTreeViewColumn *theTreeViewColumn, gpointer theUser_data)
{
translationEditor->on_sort_clicked(theTreeViewColumn, COLUMN_ORIGINAL);
}
G_MODULE_EXPORT void
on_sort_translation_clicked_cb(GtkTreeViewColumn *theTreeViewColumn, gpointer theUser_data)
{
translationEditor->on_sort_clicked(theTreeViewColumn, COLUMN_TRANSLATION);
}
G_MODULE_EXPORT void on_load_strings_clicked(GtkButton *theButton, gpointer theUser_data)
{
translationEditor->on_load_strings_clicked();
}
G_MODULE_EXPORT gboolean searchEqualFunc_cb(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data)
{
return translationEditor->searchEqualFunc(model, key, iter);
}
#ifdef __cplusplus
}
#endif
void printCmdlineUsage() {
fprintf(stdout, "SLUDGE Project Manager, usage: sludge-projectmanager \n");
}
bool parseCmdlineParameters(int argc, char *argv[]) {
int retval = true;
while (1)
{
static struct option long_options[] =
{
{"help", no_argument, 0, 'h' },
{0,0,0,0} /* This is a filler for -1 */
};
int option_index = 0;
int c = getopt_long(argc, argv, "h", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h':
default:
retval = false;
break;
}
}
return retval;
}
/*
* The main function.
*/
int
main(int argc, char *argv[])
{
char *openThisFile = argv[argc - 1];
if (! parseCmdlineParameters(argc, argv) ) {
printCmdlineUsage();
return 0;
}
if (argc < 2) {
openThisFile = NULL;
} else if (! fileExists(openThisFile) ) {
errorBox("Translation file not found!", joinTwoStrings("File not found:\n", openThisFile));
printCmdlineUsage();
return -1;
}
// On Windows, change to the program directory to
// make sure the necessary resource files are found:
winChangeToProgramDir(argv[0]);
if (!g_thread_supported ()){ g_thread_init (NULL); }
gdk_threads_init ();
gdk_threads_enter ();
/*
* Init GTK+.
*/
gtk_init(&argc, &argv);
translationEditor = new SludgeTranslationEditor();
/*
* Get the window manager to connect any assigned signals in the loaded Glade file to our coded functions.
*/
gtk_builder_connect_signals(translationEditor->theXml, NULL);
/*
* Show the window.
*/
gtk_widget_show(translationEditor->theWindow);
if (openThisFile != NULL) {
translationEditor->open(openThisFile);
}
// Run the window manager loop.
if (translationEditor->initSuccess)
gtk_main ();
delete translationEditor;
gdk_threads_leave ();
return 0;
}
sludge-2.2/GTK_Dev_Kit/SpriteBankEditor.rc 0000644 0001750 0001750 00000001610 11704133104 015342 0000000 0000000 #include "../source/CommonCode/version.h"
ID ICON "../images/spriteIcon/spriteIcon.ico"
1 VERSIONINFO
FILEVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,0,BUILD_VERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "Comments", "For more info on SLUDGE, see http://opensludge.sourceforge.net"
VALUE "CompanyName", "SLUDGE Developers"
VALUE "FileDescription", "SLUDGE Sprite Bank Editor"
VALUE "FileVersion", TEXT_VERSION
VALUE "InternalName", "sludge-spritebankeditor"
VALUE "LegalCopyright", "(C) 2000 - 2012 Hungry Software and contributors"
VALUE "OriginalFilename", "sludge-spritebankeditor.exe"
VALUE "ProductName", "SLUDGE Dev Kit"
VALUE "ProductVersion", TEXT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
sludge-2.2/GTK_Dev_Kit/support/ 0000755 0001750 0001750 00000000000 11704651221 013406 5 0000000 0000000 sludge-2.2/GTK_Dev_Kit/support/sludge.lang 0000644 0001750 0001750 00000035504 11700301465 015461 0000000 0000000
*.slu
#
(?<![\w\.])
[0-9]*
(?![\w\.])
else
event
for
if
loop
objectType
sub
while
debug
return
flag
flags
speechColour
speechColor
speechGap
spinSpeed
walkSpeed
wrapSpeech
addCharacter
addOverlay
addScreenRegion
addStatus
aimCamera
alignStatus
anim
animate
blankArea
blankScreen
bodgeFilenames
cacheSound
callEvent
cancelSub
captureAllKeys
clearStatus
completeTimers
copyStack
costume
darkBackground
deleteFile
deleteFromStack
deleteAllFromStack
dequeue
enqueue
fetchEvent
fileExists
floatCharacter
forceCharacter
freeSound
freeze
getCharacterDirection
getCharacterScale
getFramesPerSecond
getLanguageID
getMatchingFiles
getMouseScreenX
getMouseScreenY
getMouseX
getMouseY
getObjectX
getObjectY
getOverObject
getPixelColour
getPixelColor
getSoundCache
getStatusText
hardScroll
hasFlag
hideCharacter
howFrozen
isCharacter
isMoving
isScreenRegion
jumpCharacter
launch
lightStatus
loadCustomData
saveCustomData
loadGame
loopSound
mixOverlay
moveCharacter
newStack
normalCharacter
onFocusChange
onKeyboard
onLeftMouse
onLeftMouseUp
onMoveMouse
onRightMouse
onRightMouseUp
parallaxAdd
parallaxClear
pasteCharacter
pasteImage
pasteString
burnString
pause
pickOne
playSound
popFromStack
positionStatus
pushToStack
quitGame
quitWithFatalError
random
removeAllCharacters
removeAllScreenRegions
removeCharacter
removeLastStatus
removeScreenRegion
rename
renameFile
saveGame
say
think
setBackgroundEffect
doBackgroundEffect
setBlankColour
setBlankColor
setBurnColour
setBurnColor
setCharacterAngleOffset
setCharacterAntiAliasing
setCharacterColourise
setCharacterDrawMode
setCharacterExtra
setCharacterSpinSpeed
setCharacterTransparency
setCharacterWalkSpeed
setCostume
setCursor
setCustomEncoding
setDefaultMusicVolume
setDefaultSoundVolume
setFloor
setFont
setFontSpacing
setLightMap
setLitStatusColour
setLitStatusColor
setMaximumAntiAliasing
setMusicVolume
setPasteColour
setPasteColor
setScale
setSceneDimensions
setSoundLoopPoints
setSoundVolume
setSpeechMode
setSpeechSpeed
setStatusColour
setStatusColor
setThumbnailSize
setZBuffer
showBoxes
showCharacter
showFloor
showThumbnail
skipSpeech
snapshotClear
snapshotGrab
somethingSpeaking
spawnSub
stackSize
startMusic
statusText
stopCharacter
stopMusic
stopSound
stringLength
stringWidth
substring
transitionMode
transitionLevel
turnCharacter
spinCharacter
unfreeze
wait
zoomCamera
var
unfreezable
AUTOFIT
BLACK
BLINDS
CENTRE
CENTER
CROSSFADE
DARK
DARK1
DARK2
DARK3
DISOLVE
DISOLVE1
DISOLVE2
EAST
FADE
FALSE
FOGGY1
FOGGY2
FOGGY3
FOGGY4
FRONT
FIXEDSIZE
FIXTOSCREEN
GLOW
GLOW1
GLOW2
GLOW3
GLOW4
ICON
INVISIBLE
TRUE
NOLIGHTMAP
NORTH
NORTHEAST
NORTHWEST
NORMAL
NOZBUFFER
NULL
SOUTHEAST
SOUTH
SOUTHWEST
TRANSPARENT
TRANSPARENT1
TRANSPARENT2
TRANSPARENT3
SHADOW
SHADOW1
SHADOW2
SHADOW3
SOUNDANDTEXT
SOUNDONLY
TEXTONLY
TVSTATIC
WEST
WHITE
sludge-2.2/GTK_Dev_Kit/support/sludge-spritebankeditor.desktop 0000644 0001750 0001750 00000000504 11700301465 021550 0000000 0000000 [Desktop Entry]
Version=1.0
Name=SLUDGE Sprite Bank Editor
Comment=Edit SLUDGE sprite banks
Comment[de]=SLUDGE-Spritesammlungen bearbeiten
MimeType=application/x-sludge-spritebank
Exec=sludge-spritebankeditor %f
Icon=sludge-spritebankeditor
Terminal=false
Type=Application
StartupNotify=false
Categories=Development;IDE;GTK
sludge-2.2/GTK_Dev_Kit/support/48x48/ 0000755 0001750 0001750 00000000000 11704651221 014205 5 0000000 0000000 sludge-2.2/GTK_Dev_Kit/support/48x48/mimetypes/ 0000755 0001750 0001750 00000000000 11704651221 016221 5 0000000 0000000 sludge-2.2/GTK_Dev_Kit/support/48x48/mimetypes/text-x-sludge-script.png 0000644 0001750 0001750 00000011133 11700301465 022660 0000000 0000000 ‰PNG
IHDR 0 0 Wù‡ bKGD ÿ ÿ ÿ ½§“ pHYs H H FÉk> vpAg 0 0 ÎîŒW „IDAThÞÕšy\ÕuÆ÷Þ·tÏLϦ™Ñ>ÀhE "Œe0ÛØ.;xlCŒqÊ.'.W’r’rUâ,Nʱ“Êâãrl˜”p/Ø2ȼ±#@ZAҌЌz¦—×o¹÷ä×Ý3#iNòOÞÔLuÝ~ï¾óóïÜ{îÀÿóK8àœã×\˲‘³ôØèØi–ÎóŒWhÄqäy^y^V,âÁÔ#""õ(J*ÕJÒÕÕm?ñ±HoÏ\ï“Ö‡cÇËêÆ¯~]MN–‹ÇËå¾r¹Ü;88XþÊ¿ýóK7}ý6n¸îj|ßÿŸxÏ®gp^ŸŸ9þuÕª•ȲL×jµ8Š¢Iç\’$IÃZ# ˆÄq¥i:霛ÒZוR™Ö*ÕÚ€ˆHþ×ÙÌÆÚhçœÓ"R‘¾ uw— åry¿sîªÕê£ÃÃÃ|áŸ>ûÛ ¸ëGwsëw¿ÏP_ï§®¾æš¿_¸pY–a³g-Išb³iN¤)q“$ išâœÃZ‹ˆ ”r"bsÊZë5ÇÃb±HWWÝÝ%ÆÇ'xfçNž~æ™ûö8øÑzölØÙÉÖï¥Ôœ ¼S
¾í-Wð7ÿð9ºÖ¯}qr²œ.^¼È|³ˆ¤‰D)…B5¿
¥”ÐùMçdÖ