Skip to content

Commit

Permalink
ADDED more precise dragging of dialogue nodes
Browse files Browse the repository at this point in the history
ADDED conversion of '-' to '_' to create valid python files
ADDED window manager hint to (maybe) prevent tooltips from showing on top of other windows
  • Loading branch information
ksterker committed Aug 15, 2010
1 parent a160dd3 commit bf6db6d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
21 changes: 15 additions & 6 deletions src/dlgedit/dlg_compiler.cc
Expand Up @@ -29,6 +29,7 @@
#include <iterator>
#include <iostream>
#include <cstring>
#include <algorithm>
#include "dlg_cmdline.h"
#include "dlg_compiler.h"
#include "dlg_types.h"
Expand Down Expand Up @@ -93,10 +94,13 @@ void DlgCompiler::run ()
// try to open the file
std::string fname = dialogue->fullName ();

// replace '-' by '_' as python doesn't like it
std::replace (fname.begin(), fname.end(), '-', '_');

// remove the file extension
unsigned long pos = fname.rfind (FILE_EXT);
if (pos != fname.npos) fname.erase (pos);

// try to open the file
file.open ((fname + ".py").c_str ());
if (file.eof ()) return;
Expand Down Expand Up @@ -533,14 +537,19 @@ void DlgCompiler::writeDialogue ()
{
std::vector<DlgNode*> nodes = dialogue->getNodes ();
std::vector<DlgNode*>::iterator i;
DlgCircle *circle, *child;
DlgCircle *circle = NULL, *child;
DlgCircleEntry *entry;

for (i = nodes.begin (); i != nodes.end (); i++)
{
// nothing to be done for Arrows
if ((*i)->type () == LINK) continue;

// write circle coordinate for easier conversion to .adlg file
file << ")),";
if (circle != NULL) file << "\t# " << circle->x() << "," << circle->y();
file << "\n\t\t(";

circle = (DlgCircle *) (*i);

// check the conditions of the circle's children
Expand All @@ -549,8 +558,6 @@ void DlgCompiler::writeDialogue ()
// get the entry of the current circle
entry = circle->entry ();

file << ")),\\\n\t\t(";

// write Speaker
switch (circle->type ())
{
Expand Down Expand Up @@ -578,8 +585,10 @@ void DlgCompiler::writeDialogue ()
}

// end of array
file << "))]\n\n";
}
file << "))]";
if (circle != NULL) file << "\t# " << circle->x() << "," << circle->y();
file << "\n\n";
}

// write a single follower
void DlgCompiler::writeFollower (DlgNode *node)
Expand Down
5 changes: 3 additions & 2 deletions src/dlgedit/gui_graph.cc
Expand Up @@ -637,7 +637,8 @@ void GuiGraph::drag (DlgPoint &point)
point.move (-offset->x (), -offset->y ());

// move node
mover->setPos (point);
mover->setPos (DlgPoint (point.x () - (point.x () % CIRCLE_DIAMETER),
point.y () - (point.y () % CIRCLE_DIAMETER)));

// update arrows
for (DlgNode *a = mover->prev (FIRST); a != NULL; a = mover->prev (NEXT))
Expand Down Expand Up @@ -694,7 +695,7 @@ void GuiGraph::stopDragging (DlgPoint &point)
{
// make sure we drop on an empty location
DlgNode *node = module->getNode (point);
while (node != NULL && node->type() != LINK)
while (node != NULL && node != mover && node->type() != LINK)
{
point.move (0, 2*CIRCLE_DIAMETER);
node = module->getNode (point);
Expand Down
3 changes: 2 additions & 1 deletion src/dlgedit/gui_tooltip.cc
Expand Up @@ -42,7 +42,8 @@ GuiTooltip::GuiTooltip (DlgNode *n)
tooltip = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_keep_above (GTK_WINDOW (tooltip), FALSE);
gtk_window_set_transient_for (GTK_WINDOW (tooltip), GTK_WINDOW (GuiDlgedit::window->getWindow ()));

gtk_window_set_type_hint (GTK_WINDOW (tooltip), GDK_WINDOW_TYPE_HINT_TOOLTIP);

gtk_object_set_data (GTK_OBJECT (tooltip), "tip_window", tooltip);
gtk_window_set_resizable (GTK_WINDOW (tooltip), FALSE);

Expand Down

0 comments on commit bf6db6d

Please sign in to comment.