I'm designing a cross-platform map editor for an application I've developed, and I'm unsure what approach to take regarding language/gui library choice. Just for some basic info, the editor needs to parse and output xml files.
I'm most comfortable with C++, Lua, and Perl, but I'd also be willing to use Python (could use the practice). I'd prefer doing it in a scripting language for productivity.
Any recommendations are appreciated, thanks.
I'd also like support for filling out forms, etc.
P.S.开发者_Python百科 I've tested out extending existing map editors but it isn't really worth it since they don't provide the functionality I need on a fundamental level, requiring me to just re-write the whole thing anyway.
My preference is always Gtk2
and Perl 5, but that combination works best on Linux. What OS are you going to run under?
Here is an example Perl 5 script using Gtk2:
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2;
Gtk2->init;
my $window = Gtk2::Window->new;
my $vbox = Gtk2::VBox->new;
my $label = Gtk2::Label->new("click the button");
my $button = Gtk2::Button->new("click me");
my $i;
$window->signal_connect(destroy => sub { Gtk2->main_quit });
$button->signal_connect(clicked => sub { $label->set_text(++$i) });
$window->add($vbox);
$vbox->add($label);
$vbox->add($button);
$window->show_all;
Gtk2->main;
I can recommend using Python and PyQt for the job. Qt offers a class for scene management (i.e. layered object placement, zooming, hit testing, events,coordinate transformations etc., even collision detection) called QGraphicsScene and a matching control to display it all, called QGraphicsView. It also offers support for drag&drop, thus enabling interactive object placement.
Implementing a map using these classes really is just creating QGraphicItems (Rectangles, Polygons etc.) and adding them to the scene, Qt does the rest. You can have a look at how it all fits together reading the documentation, especially the document "The Graphics View Framework". I had to implement something similar for a client recently and was very pleased with this approach.
Building on the base of Lua, I would recommend IUP for the GUI. It is lightweight, portable to linux and Windows, and well integrated with Lua. For those who like Gtk, IUP includes a driver for Gtk so it can in principle be ported to any system where Gtk can port.
Another plausible choice is wxWidgets, which also has a wrapper integrating it with Lua.
Both IUP and wxWidgets are included in the Lua for Windows bundle.
精彩评论