Skip to content

Commit

Permalink
Made the editor compilable.
Browse files Browse the repository at this point in the history
For that, I splitted the luabind and the source files commonly used
into their own category in the CMakeLists.txt file.

While I added back the Qt3 backward support,
I've let small changes toward Qt4 support.

You can now build the editor using the command:
cmake -DEDITOR_SUPPORT=on .
  • Loading branch information
Yohann Ferreira committed Feb 20, 2012
1 parent 7525720 commit 53edbaf
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 103 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ install_manifest.txt
*.gmo
txt/translatable-files
src/allacrost
src/allacrost-editor

# files created during Windows build
.objs
Expand Down Expand Up @@ -41,3 +42,6 @@ doc/SOURCE/html/*

# static libraries
*.a

# files created by qmake
*.cxx
157 changes: 91 additions & 66 deletions src/CMakeLists.txt
Expand Up @@ -154,35 +154,7 @@ luabind/test/test_extend_class_in_lua.cpp
luabind/test/test_unsigned_int.cpp
)

SET(SRCS
utils.cpp
defs.h
main.cpp
common/global/global_objects.h
common/global/global_actors.cpp
common/global/global.cpp
common/global/global_effects.cpp
common/global/global_actors.h
common/global/global_utils.cpp
common/global/global.h
common/global/global_objects.cpp
common/global/global_skills.h
common/global/global_skills.cpp
common/global/global_effects.h
common/global/global_utils.h
common/common.cpp
common/dialogue.cpp
common/gui/option.h
common/gui/menu_window.cpp
common/gui/menu_window.h
common/gui/gui.h
common/gui/textbox.cpp
common/gui/textbox.h
common/gui/option.cpp
common/gui/gui.cpp
common/dialogue.h
common/common.h
common/common_bindings.cpp
SET(SRCS_LUABIND
luabind/src/class_registry.cpp
luabind/src/class_rep.cpp
luabind/src/object_rep.cpp
Expand Down Expand Up @@ -281,6 +253,77 @@ luabind/luabind/detail/call_operator_iterate.hpp
luabind/luabind/yield_policy.hpp
luabind/luabind/error.hpp
luabind/luabind/wrapper_base.hpp
)

# Files used by both the game and the editor
SET(SRCS_COMMON
common/global/global.cpp
common/global/global.h
common/global/global_actors.cpp
common/global/global_actors.h
common/global/global_effects.cpp
common/global/global_effects.h
common/global/global_objects.cpp
common/global/global_objects.h
common/global/global_skills.cpp
common/global/global_skills.h
common/global/global_utils.cpp
common/global/global_utils.h
common/common_bindings.cpp
engine/mode_manager.h
engine/mode_manager.cpp
engine/system.cpp
engine/system.h
engine/video/video.h
engine/video/video.cpp
engine/video/texture_controller.h
engine/video/texture_controller.cpp
engine/video/texture.cpp
engine/video/texture.h
engine/video/image.cpp
engine/video/image.h
engine/video/image_base.cpp
engine/video/image_base.h
engine/video/interpolator.cpp
engine/video/interpolator.h
engine/video/fade.h
engine/video/fade.cpp
engine/video/text.cpp
engine/video/text.h
engine/video/shake.cpp
engine/video/shake.h
engine/video/particle_manager.h
engine/video/particle_manager.cpp
engine/video/particle_effect.h
engine/video/particle_effect.cpp
engine/video/particle_system.h
engine/video/particle_system.cpp
engine/script/script.h
engine/script/script.cpp
engine/script/script_read.h
engine/script/script_read.cpp
engine/script/script_write.h
engine/script/script_write.cpp
utils.h
utils.cpp
defs.h
)

SET(SRCS
main.cpp
common/common.cpp
common/dialogue.cpp
common/gui/option.h
common/gui/menu_window.cpp
common/gui/menu_window.h
common/gui/gui.h
common/gui/textbox.cpp
common/gui/textbox.h
common/gui/option.cpp
common/gui/gui.cpp
common/dialogue.h
common/common.h
common/common_bindings.cpp
main_options.h
modes/pause.cpp
modes/shop/shop_root.h
Expand Down Expand Up @@ -355,20 +398,10 @@ modes/menu/menu.cpp
modes/menu/menu_views.cpp
modes/menu/menu_views.h
modes/pause.h
engine/system.cpp
engine/script/script_write.cpp
engine/script/script.h
engine/script/script.cpp
engine/script/script_modify.h
engine/script/script_write.h
engine/script/script_read.cpp
engine/script/script_read.h
engine/script/script_modify.cpp
engine/mode_manager.h
engine/system.h
engine/input.h
engine/input.cpp
engine/mode_manager.cpp
engine/audio/audio_stream.cpp
engine/audio/audio_descriptor.h
engine/audio/audio.h
Expand All @@ -381,34 +414,10 @@ engine/audio/audio_input.h
engine/audio/audio_effects.cpp
engine/engine_bindings.cpp
engine/video/screen_rect.h
engine/video/particle_system.cpp
engine/video/texture_controller.h
engine/video/color.h
engine/video/image_base.h
engine/video/particle_system.h
engine/video/particle_manager.cpp
engine/video/fade.cpp
engine/video/texture.h
engine/video/text.cpp
engine/video/interpolator.cpp
engine/video/particle_manager.h
engine/video/particle_emitter.h
engine/video/particle_keyframe.h
engine/video/interpolator.h
engine/video/fade.h
engine/video/video.h
engine/video/image.h
engine/video/text.h
engine/video/video.cpp
engine/video/particle_effect.cpp
engine/video/image_base.cpp
engine/video/shake.cpp
engine/video/shake.h
engine/video/texture_controller.cpp
engine/video/particle_effect.h
engine/video/context.h
engine/video/image.cpp
engine/video/texture.cpp
engine/video/particle.h
engine/video/effects.cpp
engine/video/coord_sys.h
Expand All @@ -425,7 +434,7 @@ ENDIF ()

SET (PROGRAMS allacrost)

ADD_EXECUTABLE(allacrost WIN32 ${SRCS})
ADD_EXECUTABLE(allacrost WIN32 ${SRCS} ${SRCS_COMMON} ${SRCS_LUABIND})

TARGET_LINK_LIBRARIES(allacrost
${INTERNAL_LIBRARIES}
Expand Down Expand Up @@ -488,16 +497,32 @@ IF (EDITOR_SUPPORT)

SET (PROGRAMS allacrost-editor)

ADD_EXECUTABLE(allacrost-editor ${SRCS_EDITOR} ${EDITOR_QT_HEADERS_MOC})
ADD_EXECUTABLE(allacrost-editor
${SRCS_EDITOR}
${SRCS_LUABIND}
${EDITOR_QT_HEADERS_MOC}
${SRCS_COMMON}
)

TARGET_LINK_LIBRARIES(allacrost-editor
${INTERNAL_LIBRARIES}
${QT_LIBRARIES}
${QT_QT3SUPPORT_LIBRARY} # for the Q3* headers.
${QT_QTOPENGL_LIBRARY}
${SDL_LIBRARY}
${SDLTTF_LIBRARY}
${OPENGL_LIBRARIES}
${OPENAL_LIBRARY}
${VORBISFILE_LIBRARIES}
${PNG_LIBRARIES}
${JPEG_LIBRARIES}
${LUA_LIBRARIES}
${X11_LIBRARIES}
${LIBINTL_LIBRARIES}
${EXTRA_LIBRARIES}
)

INSTALL(TARGETS allacrost-editor RUNTIME DESTINATION ${PKG_BINDIR})
SET_TARGET_PROPERTIES(allacrost-editor PROPERTIES COMPILE_FLAGS "${FLAGS}")
SET_TARGET_PROPERTIES(allacrost-editor PROPERTIES COMPILE_FLAGS "${FLAGS} -DQT3_SUPPORT")
ENDIF(EDITOR_SUPPORT)

12 changes: 6 additions & 6 deletions src/editor/dialog_boxes.cpp
Expand Up @@ -24,9 +24,9 @@ namespace hoa_editor {

MapPropertiesDialog::MapPropertiesDialog
(QWidget* parent, const QString& name, bool prop)
: QDialog(parent, (const char*)name)
: QDialog(parent)
{
setCaption("Map Properties...");
setWindowTitle("Map Properties...");

// Set up the height spinbox
_height_label = new QLabel("Height (in tiles):", this);
Expand Down Expand Up @@ -147,9 +147,9 @@ void MapPropertiesDialog::_EnableOKButton()
///////////////////////////////////////////////////////////////////////////////

MusicDialog::MusicDialog(QWidget* parent, const QString& name)
: QDialog(parent, name)
: QDialog(parent)
{
setCaption("Map Music Picker");
setWindowTitle("Map Music Picker");
_dia_layout = new QGridLayout(this);


Expand Down Expand Up @@ -254,9 +254,9 @@ void MusicDialog::_RemoveMusic()

ContextPropertiesDialog::ContextPropertiesDialog
(QWidget* parent, const QString& name)
: QDialog(parent, (const char*) name)
: QDialog(parent)
{
setCaption("Context Properties...");
setWindowTitle("Context Properties...");
_name_label = new QLabel("Context name", this);
_name_ledit = new QLineEdit(this);
connect(_name_ledit, SIGNAL(textEdited(const QString&)), this,
Expand Down
41 changes: 24 additions & 17 deletions src/editor/editor.cpp
Expand Up @@ -268,11 +268,13 @@ void Editor::_FileNew() {
new_map_progress->setValue(checked_items++);

TilesetTable* a_tileset = new TilesetTable();
if (a_tileset->Load(tilesets->topLevelItem(i)->text(0)) == false)
if (!a_tileset->Load(tilesets->topLevelItem(i)->text(0)))
{
const std::string mes = "Failed to load tileset image: "
+ tilesets->topLevelItem(i)->text(0).toStdString();
QMessageBox::critical(this, tr("HoA Level Editor"),
tr("Failed to load tileset image: " +
tilesets->topLevelItem(i)->text(0)));

tr(mes.c_str()));
}
_ed_tabs->addTab(a_tileset->table, tilesets->topLevelItem(i)->text(0));
_ed_scrollview->_map->tilesets.push_back(a_tileset);
_ed_scrollview->_map->tileset_names.push_back(a_tileset->tileset_name);
Expand Down Expand Up @@ -378,9 +380,13 @@ void Editor::_FileOpen() {
new_map_progress->setValue(progress_steps++);

TilesetTable* a_tileset = new TilesetTable();
if (a_tileset->Load(*it) == false)
if (!a_tileset->Load(*it))
{
const std::string mes = "Failed to load tileset image: "
+ (*it).toStdString();
QMessageBox::critical(this, tr("HoA Level Editor"),
tr("Failed to load tileset image: " + *it));
tr(mes.c_str()));
}

_ed_tabs->addTab(a_tileset->table, *it);
_ed_scrollview->_map->tilesets.push_back(a_tileset);
Expand Down Expand Up @@ -466,7 +472,7 @@ void Editor::_FileSave() {

_ed_scrollview->_map->SaveMap(); // actually saves the map
_undo_stack->setClean();
setCaption(QString("%1").arg(_ed_scrollview->_map->GetFileName()));
setWindowTitle(QString("%1").arg(_ed_scrollview->_map->GetFileName()));
statusBar()->showMessage(QString("Saved \'%1\' successfully!").
arg(_ed_scrollview->_map->GetFileName()), 5000);
}
Expand Down Expand Up @@ -500,7 +506,7 @@ void Editor::_FileClose() {
_ed_tabs = NULL;
} // tabs must exist first

setCaption("Hero of Allacrost Level Editor");
setWindowTitle("Hero of Allacrost Level Editor");
} // make sure an unsaved map is not lost
}

Expand Down Expand Up @@ -601,15 +607,16 @@ void Editor::_ViewTextures() {

void Editor::_TileLayerFill() {
// get reference to current tileset
Q3Table* table = static_cast<Q3Table*> (_ed_tabs->currentPage());
Q3Table* table = static_cast<Q3Table*> (_ed_tabs->currentWidget());

// put selected tile from tileset into tile array at correct position
int32 tileset_index = table->currentRow() * 16 + table->currentColumn();
int32 multiplier = _ed_scrollview->_map->tileset_names.findIndex(_ed_tabs->tabText(_ed_tabs->currentIndex()));
int32 multiplier = _ed_scrollview->_map->tileset_names.indexOf(_ed_tabs->tabText(_ed_tabs->currentIndex()));

if (multiplier == -1)
{
_ed_scrollview->_map->tileset_names.append(_ed_tabs->tabText(_ed_tabs->currentIndex()));
multiplier = _ed_scrollview->_map->tileset_names.findIndex(_ed_tabs->tabText(_ed_tabs->currentIndex()));
multiplier = _ed_scrollview->_map->tileset_names.indexOf(_ed_tabs->tabText(_ed_tabs->currentIndex()));
} // calculate index of current tileset

vector<int32>& current_layer = _ed_scrollview->GetCurrentLayer();
Expand Down Expand Up @@ -1430,7 +1437,7 @@ bool Editor::_EraseOK() {
///////////////////////////////////////////////////////////////////////////////

EditorScrollView::EditorScrollView(QWidget* parent, const QString& name, int width, int height) :
Q3ScrollView(parent, (const char*)name, Qt::WNoAutoErase | Qt::WStaticContents)
Q3ScrollView(parent, (const char*)name.toStdString().c_str())
{
// Set default editing modes.
_tile_mode = PAINT_TILE;
Expand Down Expand Up @@ -1609,7 +1616,7 @@ void EditorScrollView::contentsMouseMoveEvent(QMouseEvent *evt) {
(evt->x() / TILE_WIDTH) >= static_cast<uint32>(_map->GetWidth()) ||
evt->x() < 0 || evt->y() < 0 )
{
editor->statusBar()->clear();
editor->statusBar()->clearMessage();
return;
}

Expand Down Expand Up @@ -1867,7 +1874,7 @@ void EditorScrollView::contentsContextMenuEvent(QContextMenuEvent *evt) {

_tile_index = evt->y() / TILE_HEIGHT * _map->GetWidth() + evt->x() / TILE_WIDTH;
_context_menu->exec(QCursor::pos());
(static_cast<Editor*> (topLevelWidget()))->statusBar()->clear();
(static_cast<Editor*> (topLevelWidget()))->statusBar()->clearMessage();
}


Expand Down Expand Up @@ -1916,15 +1923,15 @@ void EditorScrollView::_ContextDeleteColumn() {
void EditorScrollView::_PaintTile(int32 index) {
// get reference to current tileset
Editor* editor = static_cast<Editor*> (topLevelWidget());
Q3Table* table = static_cast<Q3Table*> (editor->_ed_tabs->currentPage());
Q3Table* table = static_cast<Q3Table*> (editor->_ed_tabs->currentWidget());
QString tileset_name = editor->_ed_tabs->tabText(editor->_ed_tabs->currentIndex());
Q3TableSelection selection = table->selection(0);

int32 multiplier = _map->tileset_names.findIndex(tileset_name);
int32 multiplier = _map->tileset_names.indexOf(tileset_name);
if (multiplier == -1)
{
_map->tileset_names.append(tileset_name);
multiplier = _map->tileset_names.findIndex(tileset_name);
multiplier = _map->tileset_names.indexOf(tileset_name);
} // calculate index of current tileset

if (selection.isActive() && (selection.numCols() * selection.numRows() > 1))
Expand Down

0 comments on commit 53edbaf

Please sign in to comment.