| 1 |
/* |
| 2 |
Copyright (C) 2002 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file gui_messages.cc |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief Defines the messages to display in the status bar. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <string> |
| 27 |
#include "gui_messages.h" |
| 28 |
|
| 29 |
// define all the different messages |
| 30 |
GuiMessages::GuiMessages (GtkWidget *sb) |
| 31 |
{ |
| 32 |
current = 0; |
| 33 |
statusbar = sb; |
| 34 |
|
| 35 |
// Menu Help Messages |
| 36 |
messages[1] = " Create new dialogue"; |
| 37 |
messages[2] = " Load dialogue from disk"; |
| 38 |
messages[3] = " Save dialogue to disk"; |
| 39 |
messages[4] = " Save dialogue under new name"; |
| 40 |
messages[5] = " Close current dialogue"; |
| 41 |
messages[6] = " Exit the program"; |
| 42 |
messages[7] = " Reload dialogue from disk, discarding recent changes."; |
| 43 |
|
| 44 |
messages[10] = " Change the preferences of the current dialogue"; |
| 45 |
messages[11] = " Customize imports, constructor, destructor and methods of the dialogue script"; |
| 46 |
messages[12] = " Transform the current dialogue into a Python script, as required by the dialogue engine"; |
| 47 |
messages[13] = " Preview a translation of the current dialogue"; |
| 48 |
messages[14] = " Start the dialogue engine with the current dialogue"; |
| 49 |
|
| 50 |
messages[20] = " Switch the view to this dialogue"; |
| 51 |
|
| 52 |
// Dialogue Editing Help Messages |
| 53 |
messages[100] = " LEFT-click to select Circle or MIDDLE-click to edit it"; |
| 54 |
messages[101] = " LEFT-click to select Arrow"; |
| 55 |
messages[102] = " LEFT-click to create new Circle"; |
| 56 |
|
| 57 |
messages[110] = " RIGHT-click to cancel selection or press DEL to delete selected node"; |
| 58 |
messages[111] = " LEFT-click to connect the two Circles"; |
| 59 |
messages[112] = " LEFT-click to create new Circle, connected with the selected one"; |
| 60 |
messages[113] = " MIDDLE-click/press ENTER to edit selected Circle"; |
| 61 |
|
| 62 |
messages[120] = " Release LEFT mouse button to attach Arrow to this Circle"; |
| 63 |
|
| 64 |
messages[130] = " All editing functions are disabled. Press CTRL+V to leave preview mode"; |
| 65 |
|
| 66 |
// Report Success |
| 67 |
messages[200] = " Loading successful"; |
| 68 |
messages[201] = " Saving successful"; |
| 69 |
messages[202] = " Sub-dialogue loaded successfully"; |
| 70 |
|
| 71 |
messages[210] = " Settings updated"; |
| 72 |
messages[211] = " Custom code updated"; |
| 73 |
messages[212] = " Dialogue compiled successfully"; |
| 74 |
|
| 75 |
// Welcome Message |
| 76 |
messages[1000] = " Welcome to the Adonthell Dialogue Editor"; |
| 77 |
|
| 78 |
// Report Failure |
| 79 |
messages[-2] = " Could not open '%s'. Please make sure the file exists and is readable"; |
| 80 |
messages[-3] = " Could not load '%s'. Either this is no dialogue source, or it has been corrupted"; |
| 81 |
messages[-4] = " Saving of '%s' failed."; |
| 82 |
|
| 83 |
messages[-100] = " Cannot connect two PLAYER Circles"; |
| 84 |
|
| 85 |
// Preview Translations |
| 86 |
messages[-130] = " '%s' does not appear to be a binary catalog file"; |
| 87 |
messages[-131] = " Failed to create temporary locale dir"; |
| 88 |
} |
| 89 |
|
| 90 |
// display a message to the statusbar |
| 91 |
void GuiMessages::display (int id) |
| 92 |
{ |
| 93 |
// no change needed |
| 94 |
if (id == current) return; |
| 95 |
|
| 96 |
const char *message = messages[id]; |
| 97 |
|
| 98 |
// some context id the statusbar needs for some reason |
| 99 |
id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "Message"); |
| 100 |
|
| 101 |
// remove the previous message |
| 102 |
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), id); |
| 103 |
|
| 104 |
// add the new status |
| 105 |
gtk_statusbar_push (GTK_STATUSBAR (statusbar), id, message); |
| 106 |
} |
| 107 |
|
| 108 |
// display a message with some custom text inserted |
| 109 |
void GuiMessages::display (int id, const char* text) |
| 110 |
{ |
| 111 |
if (id == current) return; |
| 112 |
|
| 113 |
std::string message (messages[id]); |
| 114 |
unsigned long pos = message.find ("%s"); |
| 115 |
|
| 116 |
// insert text into the message |
| 117 |
if (pos != message.npos) |
| 118 |
message.replace (pos, 2, text); |
| 119 |
|
| 120 |
// some context id the statusbar needs for some reason |
| 121 |
id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "Message"); |
| 122 |
|
| 123 |
// remove the previous message |
| 124 |
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), id); |
| 125 |
|
| 126 |
// add the new status |
| 127 |
gtk_statusbar_push (GTK_STATUSBAR (statusbar), id, message.c_str ()); |
| 128 |
} |
| 129 |
|
| 130 |
// clear the statusbar |
| 131 |
void GuiMessages::clear () |
| 132 |
{ |
| 133 |
// some context id the statusbar needs for some reason |
| 134 |
int id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "Message"); |
| 135 |
|
| 136 |
// remove the previous message |
| 137 |
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), id); |
| 138 |
} |