diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..da36aee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,79 @@ +language: cpp + +sudo: false + +matrix: + include: + - os: linux + sudo: required + #dist: trusty + compiler: clang + - os: osx + compiler: clang + +git: + depth: 5 + +addons: + apt: + packages: + - mesa-common-dev + - swig + - libsdl2-dev + - libsdl2-image-dev + - libsdl2-ttf-dev + - libfreetype6-dev + - libxcursor-dev + - libopenal-dev + - libasound2-dev + - zlib1g-dev + - libboost-dev + - libboost-regex-dev + - libboost-system-dev + - libboost-filesystem-dev + - libboost-test-dev + - libtinyxml-dev + - libglew-dev + +before_install: + # Swig (we need 3.0.8+) + - if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository ppa:timsc/swig-3.0.12 -y; sudo apt-get update -q; sudo apt-get install swig; fi + # fetch additional libs + - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get -qq update && sudo apt-get install -y libgle3-dev liballegro5-dev libvorbis-dev libalut-dev cppcheck; fi + - if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install swig sdl2 sdl2_image sdl2_ttf allegro freetype openal-soft tinyxml glew; fi + # + # install fifechan + # + - git clone --quiet --depth 1 git://github.com/fifengine/fifechan.git + - mkdir build_fifechan + - cd build_fifechan + - cmake ../fifechan + - make -j4 VERBOSE=1 + - sudo make install + - cd .. + # + # install fife + # + - git clone --quiet --depth 1 git://github.com/fifengine/fifengine.git + - mkdir build_fifengine + - cd build_fifengine + - cmake ../fifengine -Dbuild-library:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF + - make -j4 VERBOSE=1 + - sudo make install + - cd .. + +# build fifengine-cpp-tutorials +script: + # leave /home/travis/build/fifengine/cpp-tutorials + - cd .. + # start out-of-source-tree build + - mkdir build_cpp_tutorials + - cd build_cpp_tutorials + - cmake ../cpp-tutorials/src + - make -j4 VERBOSE=1 + - sudo make install + - cd .. + +#notifications: +# irc: "irc.freenode.org#fife" +# email: false diff --git a/README.md b/README.md index 6d1b781..e16087a 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,39 @@ -# Introduction -The instructions below will guide you through downloading and setting up the fife engine as well as the fife-tutorials. - -# Windows Install -* Download the FIFE 0.3.4 win32 installer from sourceforge and run the installer -* Checkout the fife-tutorials trunk to the location `/tutorials` - -## Using Visual Studio -* Execute the script `/build/win32/update_project_files.bat` -* Navigate to `/build/win32/build_environments/visual_studio_#` where # is the version of visual studio you are using -* Open the solution `fife_engine.sln` -* Go to the build configurations menu within visual studio and select either the `Debug_static` or `Release_static` configuration -* Build the solution and make sure no errors occurred -* Navigate to `/tutorials/build/` and choose the directory based on which version of visual studio you are using -* Open the solution (.sln) file within the directory -* Set the build configuration within visual studio to either "Debug" or "Release" to correspond to how FIFE was built -* Build solution and make sure no errors occurred - -## Using Mingw -TBD - -#Linux Install -* Download the [latest FIFE source code](https://sourceforge.net/projects/fife/files/active/src/) and extract it. Be sure to have all the [build dependencies](https://github.com/fifengine/fifengine/wiki/dependencies) installed. -* Extract the source and change directory into the source dir. `fife_0.3.4` for example. -* Next `cd ext/guichan && ./configure && make && sudo make install && cd -`. You have to have guichan installed in `/usr/local` for the cmake file to work properly. If you use `scons ext` you'll need to modify the `CMakeLists.txt` file with the proper paths. -* Type: `sudo scons install-dev`. Once that is complete you should have a good copy of the fife library in `/usr/local/lib` -* Clone this repository. `git clone https://github.com/fifengine/cpp-tutorials.git` -* `cd cpp-tutorials/src/tutorial_1` -* `cmake .` -* `make` -* Assuming that all went well go ahead and run the tutorial: `./Tutorial1` +## FIFE C++ Tutorials + +[![Build status](https://ci.appveyor.com/api/projects/status/w68crw0n1ce75ccv?svg=true)](https://ci.appveyor.com/project/jakoch/fifengine-cpp-tutorials) +[![Build Status](https://travis-ci.org/fifengine/cpp-tutorials.svg?branch=master)](https://travis-ci.org/fifengine/cpp-tutorials) + +This set of tutorials will guide you through using FIFE to power your game. + +## Installation + +### Windows + +Run build.bat file + +### Linux + +Compiling: + +cd src; mkdir _build; cd _build; cmake .. + +Run: + +cd src/_build/tutorial_1/ ./Tutorial1 + +## Tutorials Overview + +### Tutorial 1 + +Tutorial 1 shows you how to do the following with FIFE: + +1. Engine initialization and setup +2. Setting up user input +3. Loading a map +4. Manipulating the camera through input keys and mouse +5. Moving characters on screen +6. Auto screen scrolling based on mouse cursor position + +## Contribute + +Please fork the project, if you would like to contribute! diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..a4163cd --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,91 @@ +# Build worker image (VM template) +image: Visual Studio 2015 + +# scripts that are called at very beginning, before repo cloning +init: + - date /T & time /T + - git config --global core.autocrlf input + - cmake --version + # go to hell Xamarin (see http://help.appveyor.com/discussions/problems/4569) + - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets" + # Set "build version number" to "short-commit-hash" or when tagged to "tag name" (Travis style) + - ps: >- + if ($env:APPVEYOR_REPO_TAG -eq "true") + { + Update-AppveyorBuild -Version "$env:APPVEYOR_REPO_TAG_NAME" + } + else + { + Update-AppveyorBuild -Version "dev-$($env:APPVEYOR_REPO_COMMIT.substring(0,7))" + } + +branches: + only: + - master + +clone_depth: 5 + +version: '{build}' + +platform: + - x86 + +configuration: + - Release + #- Debug + +environment: + MSBUILD_FLAGS: /verbosity:minimal /maxcpucount + matrix: + - generator: "Visual Studio 14" + #- generator: "MinGW Makefiles" + +matrix: + fast_finish: true + +#cache: +# - c:\project\fifengine-cpp-tutorials\dependencies + +install: + # install fifengine + - curl -LfsS -o libfife.zip https://ci.appveyor.com/api/buildjobs/7xflrp0frgit15u5/artifacts/libfife-dev-c4d5f09-VC14.zip + - 7z x libfife.zip -o%APPVEYOR_BUILD_FOLDER%\dependencies -y > nul + # install fifengine dependencies + - curl -LfsS -o libfife-deps.zip https://ci.appveyor.com/api/buildjobs/7xflrp0frgit15u5/artifacts/libfife-dependencies-dev-c4d5f09-VC14.zip + - 7z x libfife-deps.zip -o%APPVEYOR_BUILD_FOLDER%\dependencies -y > nul + +build_script: + - cd %APPVEYOR_BUILD_FOLDER% + - dir + # create folder for an out-of-source-tree build: "c:\projects\build" + - cd.. + - mkdir build + - cd build + # generate build script + - > + cmake %APPVEYOR_BUILD_FOLDER%\src + -G "%generator%" + -DCMAKE_INSTALL_PREFIX=./tutorials + # build + - cmake --build . --target ALL_BUILD --config %configuration% -- /nologo /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + # install + - cmake --build . --target INSTALL --config %configuration% -- /nologo + # package (with cpack) + #- cmake --build ./build --target PACKAGE --config %configuration% -- /nologo + +after_build: + # set compiler var + - if "%generator%"=="Visual Studio 14" (set COMPILER="VC14") + - if "%generator%"=="MinGW Makefiles" (set COMPILER="MinGW") + # copy required system libraries from \bin folder into \Tutorials1 folder + - xcopy C:\projects\build\tutorials\bin\*.* C:\projects\build\tutorials\Tutorial1 + - rd /s /q C:\projects\build\tutorials\bin + # switch to project build folder and zip "tutorials" folder + - cd C:\projects\build + - 7z a -tzip -mx9 "tutorials-%APPVEYOR_BUILD_VERSION%-%COMPILER%.zip" tutorials + # switch to project directory and zip append the "assets" folder + - cd %APPVEYOR_BUILD_FOLDER% + - 7z a -tzip -mx9 "C:\projects\build\tutorials-%APPVEYOR_BUILD_VERSION%-%COMPILER%.zip" assets + # finally, push the tutorials artifact + - cd C:\projects\build + - appveyor PushArtifact "tutorials-%APPVEYOR_BUILD_VERSION%-%COMPILER%.zip" diff --git a/assets/maps/shrine.xml b/assets/maps/shrine.xml index 77c24e2..fed8be8 100644 --- a/assets/maps/shrine.xml +++ b/assets/maps/shrine.xml @@ -6059,8 +6059,8 @@ - + - + diff --git a/assets/objects/ground1.png b/assets/objects/ground1.png index 1aa0925..a5fcedc 100644 Binary files a/assets/objects/ground1.png and b/assets/objects/ground1.png differ diff --git a/assets/objects/ground1.xml b/assets/objects/ground1.xml index 34b9140..3091d0a 100644 --- a/assets/objects/ground1.xml +++ b/assets/objects/ground1.xml @@ -1,12 +1,12 @@ - - - - - - - + + + + + + + diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..c0a3b01 --- /dev/null +++ b/build.bat @@ -0,0 +1,21 @@ +@echo off + +set configuration=Release + +:: configure + +d:\cmake\bin\cmake src/CMakeLists.txt -B./build -DCMAKE_INSTALL_PREFIX=./tutorials + +:: make + +d:\cmake\bin\cmake --build ./build --target ALL_BUILD --config %configuration% -- /nologo + +:: install + +d:\cmake\bin\cmake --build ./build --target INSTALL --config %configuration% -- /nologo + +:: package (with cpack) + +: d:\cmake\bin\cmake --build ./build --target PACKAGE --config %configuration% -- /nologo + +pause \ No newline at end of file diff --git a/src/CMake/Modules/FindFife.cmake b/src/CMake/Modules/FindFife.cmake new file mode 100644 index 0000000..8af2cdb --- /dev/null +++ b/src/CMake/Modules/FindFife.cmake @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------------ +# FindFife.cmake +#------------------------------------------------------------------------------ +# +# Find the native fife includes and libraries. Detect Fife version. +# +# FIFE_INCLUDE_DIR - where to find fife/core/version.h, etc. +# FIFE_LIBRARIES - List of libraries when using fife. +# FIFE_FOUND - True, if fife found. +# +#------------------------------------------------------------------------------ +# Author: Jens A. Koch +#------------------------------------------------------------------------------ + +if(FIFE_INCLUDE_DIR) + # Already in cache, be silent + set(FIFE_FIND_QUIETLY TRUE) +endif(FIFE_INCLUDE_DIR) + +find_path(FIFE_INCLUDE_DIR fife/core/version.h) + +# append "fife/core" to "include" path +set(FIFE_INCLUDE_DIR ${FIFE_INCLUDE_DIR}/fife/core) + +#------------------------------------------------------------------------------ +# Detect Version +#------------------------------------------------------------------------------ + +if(FIFE_INCLUDE_DIR AND EXISTS "${FIFE_INCLUDE_DIR}/version.h") + file(STRINGS "${FIFE_INCLUDE_DIR}/version.h" FIFE_VERSION_LINE REGEX "^(.+)([0-9]+)\\.([0-9]+)\\.([0-9]+)\"$") + string(REGEX REPLACE "^[ \t]#define FIFE_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"$" "\\1.\\2.\\3" FIFE_VERSION "${FIFE_VERSION_LINE}") + set(FIFE_VERSION_STRING ${FIFE_VERSION}) + unset(FIFE_VERSION_LINE) + unset(FIFE_VERSION) +endif() + +# MSVC built fife may be named fife_static. +# The provided project files name the library with the lib prefix. +find_library(FIFE_LIBRARY NAMES fife fife_static libfife libfife_static) + +# Handle the QUIETLY and REQUIRED arguments and set FIFE_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(FIFE + REQUIRED_VARS FIFE_LIBRARY FIFE_INCLUDE_DIR + VERSION_VAR FIFE_VERSION_STRING +) + +if(FIFE_FOUND) + set(FIFE_LIBRARIES ${FIFE_LIBRARY}) +endif(FIFE_FOUND) + +mark_as_advanced(FIFE_INCLUDE_DIR FIFE_LIBRARY) \ No newline at end of file diff --git a/src/CMake/Modules/FindFifeChan.cmake b/src/CMake/Modules/FindFifeChan.cmake new file mode 100644 index 0000000..cca181c --- /dev/null +++ b/src/CMake/Modules/FindFifeChan.cmake @@ -0,0 +1,79 @@ +#------------------------------------------------------------------------------ +# FindFifeChan.cmake +#------------------------------------------------------------------------------ +# +# Find the native fifechan includes and libraries. Supports components. +# +# Usage: find_package(FifeChan COMPONENTS opengl sdl REQUIRED) +# +# FIFECHAN_INCLUDE_DIR - where to find fifechan/fifechan.h, etc. +# FIFECHAN_LIBRARIES - List of libraries when using fifechan. +# FIFECHAN_FOUND - True, if fifechan found. +# +# FIFECHAN_${component}_FOUND - True, if fifechan_component found. +# +#------------------------------------------------------------------------------ +# Author: Jens A. Koch +#------------------------------------------------------------------------------ + +if(FIFECHAN_INCLUDE_DIR) + # Already in cache, be silent + set(FIFECHAN_FIND_QUIETLY TRUE) +endif(FIFECHAN_INCLUDE_DIR) + +#------------------------------------------------------------------------------ +# Find FIFECHAN_INCLUDE_DIR +#------------------------------------------------------------------------------ + +find_path(FIFECHAN_INCLUDE_DIR fifechan/fifechan.hpp) + +# append "fifechan" to "include" path +set(FIFECHAN_INCLUDE_DIR ${FIFECHAN_INCLUDE_DIR}/fifechan) + +#------------------------------------------------------------------------------ +# Find FIFECHAN_LIBRARY +#------------------------------------------------------------------------------ + +# support alternative library names: suffix "_static" and prefix "lib" +find_library(FIFECHAN_LIBRARY NAMES fifechan fifechan_static libfifechan libfifechan_static) + +#------------------------------------------------------------------------------ +# Find libraries (components) +# +# Example: find_package(FifeChan COMPONENTS opengl sdl REQUIRED) +#------------------------------------------------------------------------------ + +IF(FifeChan_FIND_COMPONENTS) + + message(STATUS "Found the following FifeChan libraries:") + + FOREACH(component ${FifeChan_FIND_COMPONENTS}) + + find_library(FIFECHAN_${component}_LIBRARY NAMES fifechan_${component}) + + if(FIFECHAN_${component}_LIBRARY) + SET(FIFECHAN_${component}_FOUND 1) + list(APPEND FIFECHAN_COMPONENTS "${FIFECHAN_${component}_LIBRARY}") + message(STATUS " fifechan_${component}") + else() + SET(FIFECHAN_${component}_FOUND 0) + message(STATUS " fifechan_${component} not found.") + endif() + + ENDFOREACH() +ENDIF() + +# - handle the QUIETLY and REQUIRED arguments +# - set FIFECHAN_FOUND to TRUE if all REQUIRED_VARS are TRUE +# - additionally handle components, which are found: FIFECHAN_${component}_FOUND +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FIFECHAN + REQUIRED_VARS FIFECHAN_LIBRARY FIFECHAN_INCLUDE_DIR + HANDLE_COMPONENTS +) + +if(FIFECHAN_FOUND) + set(FIFECHAN_LIBRARIES ${FIFECHAN_LIBRARY} ${FIFECHAN_COMPONENTS}) +endif(FIFECHAN_FOUND) + +mark_as_advanced(FIFECHAN_INCLUDE_DIR FIFECHAN_LIBRARY) \ No newline at end of file diff --git a/src/CMake/Modules/FindOgg.cmake b/src/CMake/Modules/FindOgg.cmake new file mode 100644 index 0000000..6309870 --- /dev/null +++ b/src/CMake/Modules/FindOgg.cmake @@ -0,0 +1,28 @@ +# - FindOgg.cmake +# Find the native ogg includes and libraries +# +# OGG_INCLUDE_DIR - where to find ogg/ogg.h, etc. +# OGG_LIBRARIES - List of libraries when using ogg. +# OGG_FOUND - True if ogg found. + +if(OGG_INCLUDE_DIR) + # Already in cache, be silent + set(OGG_FIND_QUIETLY TRUE) +endif(OGG_INCLUDE_DIR) + +find_path(OGG_INCLUDE_DIR ogg/ogg.h) + +# MSVC built ogg may be named ogg_static. +# The provided project files name the library with the lib prefix. +find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static) + +# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OGG DEFAULT_MSG OGG_LIBRARY OGG_INCLUDE_DIR) + +if(OGG_FOUND) + set(OGG_LIBRARIES ${OGG_LIBRARY}) +endif(OGG_FOUND) + +mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY) \ No newline at end of file diff --git a/src/CMake/Modules/FindSDL2.cmake b/src/CMake/Modules/FindSDL2.cmake new file mode 100644 index 0000000..026dc34 --- /dev/null +++ b/src/CMake/Modules/FindSDL2.cmake @@ -0,0 +1,169 @@ + +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not . This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +message("") + +SET(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${SDL2_PATH} +) + +FIND_PATH(SDL2_INCLUDE_DIR SDL.h + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES include/SDL2 include + PATHS ${SDL2_SEARCH_PATHS} +) + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional library, mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows +# (Actually on second look, I think it only needs one of the m* libraries.) +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +IF(SDL2_LIBRARY_TEMP) + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") +ENDIF(SDL2_LIBRARY_TEMP) + +message("") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + diff --git a/src/CMake/Modules/FindSDL2_image.cmake b/src/CMake/Modules/FindSDL2_image.cmake new file mode 100644 index 0000000..c845f25 --- /dev/null +++ b/src/CMake/Modules/FindSDL2_image.cmake @@ -0,0 +1,100 @@ +# Locate SDL_image library +# +# This module defines: +# +# :: +# +# SDL_IMAGE_LIBRARIES, the name of the library to link against +# SDL_IMAGE_INCLUDE_DIRS, where to find the headers +# SDL_IMAGE_FOUND, if false, do not try to link against +# SDL_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image +# +# +# +# For backward compatiblity the following variables are also set: +# +# :: +# +# SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES) +# SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS) +# SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND) +# +# +# +# $SDLDIR is an environment variable that would correspond to the +# ./configure --prefix=$SDLDIR used in building SDL. +# +# Created by Eric Wing. This was influenced by the FindSDL.cmake +# module, but with modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). + +#============================================================================= +# Copyright 2005-2009 Kitware, Inc. +# Copyright 2012 Benjamin Eikel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h + HINTS + ENV SDL2IMAGEDIR + ENV SDL2DIR + PATH_SUFFIXES SDL2 + # path suffixes to search inside ENV{SDLDIR} + include/SDL2 include + PATHS ${SDL2_PATH} + ) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +find_library(SDL2_IMAGE_LIBRARY + NAMES SDL2_image + HINTS + ENV SDL2IMAGEDIR + ENV SDL2DIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATHS ${SDL2_PATH} + ) + +if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h") + file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}") + set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH}) + unset(SDL2_IMAGE_VERSION_MAJOR_LINE) + unset(SDL2_IMAGE_VERSION_MINOR_LINE) + unset(SDL2_IMAGE_VERSION_PATCH_LINE) + unset(SDL2_IMAGE_VERSION_MAJOR) + unset(SDL2_IMAGE_VERSION_MINOR) + unset(SDL2_IMAGE_VERSION_PATCH) +endif() + +set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY}) +set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image + REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS + VERSION_VAR SDL2_IMAGE_VERSION_STRING) + +# for backward compatiblity +#set(SDLIMAGE_LIBRARY ${SDL_IMAGE_LIBRARIES}) +#set(SDLIMAGE_INCLUDE_DIR ${SDL_IMAGE_INCLUDE_DIRS}) +#set(SDLIMAGE_FOUND ${SDL_IMAGE_FOUND}) + +mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR) diff --git a/src/CMake/Modules/FindSDL2_ttf.cmake b/src/CMake/Modules/FindSDL2_ttf.cmake new file mode 100644 index 0000000..28f4bf4 --- /dev/null +++ b/src/CMake/Modules/FindSDL2_ttf.cmake @@ -0,0 +1,98 @@ +# Locate SDL_image library +# +# This module defines: +# +# :: +# +# SDL_TTF_LIBRARIES, the name of the library to link against +# SDL_TTF_INCLUDE_DIRS, where to find the headers +# SDL_TTF_FOUND, if false, do not try to link against +# SDL_F_VERSION_STRING - human-readable string containing the version of SDL_ttf +# +# +# +# For backward compatiblity the following variables are also set: +# +# :: +# +# SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES) +# SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS) +# SDLTTF_FOUND (same value as SDL_TTF_FOUND) +# +# +# +# $SDLDIR is an environment variable that would correspond to the +# ./configure --prefix=$SDLDIR used in building SDL. +# +# Created by Eric Wing. This was influenced by the FindSDL.cmake +# module, but with modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). + +#============================================================================= +# Copyright 2005-2009 Kitware, Inc. +# Copyright 2012 Benjamin Eikel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h + HINTS + ENV SDL2TTFDIR + ENV SDL2DIR + PATH_SUFFIXES SDL2 + # path suffixes to search inside ENV{SDLDIR} + include/SDL2 include + PATHS ${SDL2_PATH} + ) + +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else () + set(VC_LIB_PATH_SUFFIX lib/x86) +endif () + +find_library(SDL2_TTF_LIBRARY + NAMES SDL2_ttf + HINTS + ENV SDL2TTFDIR + ENV SDL2DIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATHS ${SDL2_PATH} + ) + +if (SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h") + file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}") + set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH}) + unset(SDL2_TTF_VERSION_MAJOR_LINE) + unset(SDL2_TTF_VERSION_MINOR_LINE) + unset(SDL2_TTF_VERSION_PATCH_LINE) + unset(SDL2_TTF_VERSION_MAJOR) + unset(SDL2_TTF_VERSION_MINOR) + unset(SDL2_TTF_VERSION_PATCH) +endif () + +set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY}) +set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf + REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS + VERSION_VAR SDL2_TTF_VERSION_STRING) + +# for backward compatiblity +#set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES}) +#set(SDLTTF_INCLUDE_DIR ${SDL_TTF_INCLUDE_DIRS}) +#set(SDLTTF_FOUND ${SDL_TTF_FOUND}) diff --git a/src/CMake/Modules/FindTinyXML.cmake b/src/CMake/Modules/FindTinyXML.cmake new file mode 100644 index 0000000..33b0c16 --- /dev/null +++ b/src/CMake/Modules/FindTinyXML.cmake @@ -0,0 +1,104 @@ +################################################################################################## +#Copyright (c) 2013, Open Source Robotics Foundation +#All rights reserved. +# +#Redistribution and use in source and binary forms, with or without modification, +#are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# Neither the name of the {organization} nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +#ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +################################################################################################## + +################################################################################################## +# +# CMake script for finding TinyXML. +# +# Input variables: +# +# - TinyXML_ROOT_DIR (optional): When specified, header files and libraries will be searched for in +# ${TinyXML_ROOT_DIR}/include +# ${TinyXML_ROOT_DIR}/libs +# respectively, and the default CMake search order will be ignored. When unspecified, the default +# CMake search order is used. +# This variable can be specified either as a CMake or environment variable. If both are set, +# preference is given to the CMake variable. +# Use this variable for finding packages installed in a nonstandard location, or for enforcing +# that one of multiple package installations is picked up. +# +# +# Cache variables (not intended to be used in CMakeLists.txt files) +# +# - TinyXML_INCLUDE_DIR: Absolute path to package headers. +# - TinyXML_LIBRARY: Absolute path to library. +# +# +# Output variables: +# +# - TinyXML_FOUND: Boolean that indicates if the package was found +# - TinyXML_INCLUDE_DIRS: Paths to the necessary header files +# - TinyXML_LIBRARIES: Package libraries +# +# +# Example usage: +# +# find_package(TinyXML) +# if(NOT TinyXML_FOUND) +# # Error handling +# endif() +# ... +# include_directories(${TinyXML_INCLUDE_DIRS} ...) +# ... +# target_link_libraries(my_target ${TinyXML_LIBRARIES}) +# +################################################################################################## + +# Get package location hint from environment variable (if any) +if(NOT TinyXML_ROOT_DIR AND DEFINED ENV{TinyXML_ROOT_DIR}) + set(TinyXML_ROOT_DIR "$ENV{TinyXML_ROOT_DIR}" CACHE PATH + "TinyXML base directory location (optional, used for nonstandard installation paths)") +endif() + +# Search path for nonstandard package locations +if(TinyXML_ROOT_DIR) + set(TinyXML_INCLUDE_PATH PATHS "${TinyXML_ROOT_DIR}/include" NO_DEFAULT_PATH) + set(TinyXML_LIBRARY_PATH PATHS "${TinyXML_ROOT_DIR}/lib" NO_DEFAULT_PATH) +endif() + +# Find headers and libraries +find_path(TinyXML_INCLUDE_DIR NAMES tinyxml.h PATH_SUFFIXES "tinyxml" ${TinyXML_INCLUDE_PATH}) +find_library(TinyXML_LIBRARY NAMES tinyxml PATH_SUFFIXES "tinyxml" ${TinyXML_LIBRARY_PATH}) + +mark_as_advanced(TinyXML_INCLUDE_DIR + TinyXML_LIBRARY) + +# Output variables generation +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(TinyXML DEFAULT_MSG TinyXML_LIBRARY + TinyXML_INCLUDE_DIR) + +set(TinyXML_FOUND ${TINYXML_FOUND}) # Enforce case-correctness: Set appropriately cased variable... +unset(TINYXML_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args + +if(TinyXML_FOUND) + set(TinyXML_INCLUDE_DIRS ${TinyXML_INCLUDE_DIR}) + set(TinyXML_LIBRARIES ${TinyXML_LIBRARY}) +endif() diff --git a/src/CMake/Modules/FindVorbis.cmake b/src/CMake/Modules/FindVorbis.cmake new file mode 100644 index 0000000..0efa0bc --- /dev/null +++ b/src/CMake/Modules/FindVorbis.cmake @@ -0,0 +1,35 @@ +# - FindVorbis.cmake +# Find the native vorbis includes and libraries +# +# VORBIS_INCLUDE_DIR - where to find vorbis/vorbis.h, etc. +# VORBIS_LIBRARIES - List of libraries when using vorbis(file). +# VORBIS_FOUND - True if vorbis found. + +if(VORBIS_INCLUDE_DIR) + # Already in cache, be silent + set(VORBIS_FIND_QUIETLY TRUE) +endif(VORBIS_INCLUDE_DIR) + +find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) + +# MSVC built vorbis may be named vorbis_static +# The provided project files name the library with the lib prefix. +find_library(VORBIS_LIBRARY + NAMES vorbis vorbis_static libvorbis libvorbis_static +) +find_library(VORBISFILE_LIBRARY + NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static +) + +# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VORBIS DEFAULT_MSG + VORBISFILE_LIBRARY VORBIS_LIBRARY VORBIS_INCLUDE_DIR +) + +if(VORBIS_FOUND) + set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY}) +endif(VORBIS_FOUND) + +mark_as_advanced(VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY) \ No newline at end of file diff --git a/src/CMake/Modules/FindXcursor.cmake b/src/CMake/Modules/FindXcursor.cmake new file mode 100644 index 0000000..6913d9f --- /dev/null +++ b/src/CMake/Modules/FindXcursor.cmake @@ -0,0 +1,36 @@ +#------------------------------------------------------------------------------ +# FindXcursor.cmake +#------------------------------------------------------------------------------ +# +# Find the X11 Xcursor lib and define the following vars: +# +# XCURSOR_FOUND - true, if XCURSOR_INCLUDE_DIR and XCURSOR_LIBRARY are found +# XCURSOR_LIBRARIES - Set when XCURSOR_LIBRARY is found +# XCURSOR_INCLUDE_DIRS - Set when XCURSOR_INCLUDE_DIR is found +# +# XCURSOR_INCLUDE_DIR - where to find Xcursor.h +# XCURSOR_LIBRARY - the Xcursor library +# +#------------------------------------------------------------------------------ +# Author: Jens A. Koch +#------------------------------------------------------------------------------ + +find_path(XCURSOR_INCLUDE_DIR NAMES X11/Xcursor/Xcursor.h + PATH_SUFFIXES X11/Xcursor + PATHS /opt/X11/include +) + +find_library(XCURSOR_LIBRARY NAMES Xcursor + PATHS /opt/X11/lib +) + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xcursor DEFAULT_MSG XCURSOR_LIBRARY XCURSOR_INCLUDE_DIR) + +if(XCURSOR_FOUND) + set( XCURSOR_LIBRARIES ${XCURSOR_LIBRARY} ) + set( XCURSOR_INCLUDE_DIRS ${XCURSOR_INCLUDE_DIR} ) +endif() + +mark_as_advanced(XCURSOR_INCLUDE_DIR XCURSOR_LIBRARY) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03210e9..51c6190 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,55 +1,134 @@ -# define the minimum cmake version supported -cmake_minimum_required(VERSION 2.6) +#------------------------------------------------------------------------------ +# Fifengine C++ Tutorials +#------------------------------------------------------------------------------ + +cmake_minimum_required(VERSION 2.8) -# define project name project(fife-cpp-tutorials) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +#------------------------------------------------------------------------------ +# Configure +#------------------------------------------------------------------------------ -if(WIN32) - set(OUTPUT_DIR ${PROJECT_SOURCE_DIR}/../bin) - set(LIBRARY_BASE_DIR ${PROJECT_SOURCE_DIR}/../../build/win32/static_libs) - set(INC_BASE_DIR ${PROJECT_SOURCE_DIR}/../../build/win32/includes) - set(EXT_DLL_BASE_DIR ${PROJECT_SOURCE_DIR}/../../build/win32/binaries) - - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/boost_1_47_0;${CMAKE_INCLUDE_PATH}") - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/sdl_image;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/sdl;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/sdl_ttf;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/zlib;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/openal/AL;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/libpng;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/libvorbis;${CMAKE_INCLUDE_PATH}) - set(CMAKE_INCLUDE_PATH "${INC_BASE_DIR}/libogg;${CMAKE_INCLUDE_PATH}) - - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY${OUTPUT_DIR}) - foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR}) - endforeach() - - if(MSVC10) - set(CMAKE_LIBRARY_PATH ${LIBRARY_BASE_DIR}/msvc2010) - set(EXT_DLL_DIR ${EXT_DLL_BASE_DIR}/msvc2010) - elseif (MSVC90) - set(CMAKE_LIBRARY_PATH ${LIBRARY_BASE_DIR}/msvc2008) - set(EXT_DLL_DIR ${EXT_DLL_BASE_DIR}/msvc2008) - elseif(MSVC80) - set(CMAKE_LIBRARY_PATH ${LIBRARY_BASE_DIR}/msvc2005) - set(EXT_DLL_DIR ${EXT_DLL_BASE_DIR}/msvc2005) - elseif(MINGW) - set(CMAKE_LIBRARY_PATH ${LIBRARY_BASE_DIR}/mingw) - set(EXT_DLL_DIR ${EXT_DLL_BASE_DIR}/mingw) - endif() - - # make sure boost options are set properly - add_definitionS(-DBOOST_ALL_NO_LIB) - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_MULTITHREADED ON) - unset(Boost_INCLUDE_DIR CACHE) - unset(Boost_LIBRARY_DIRS CACHE) +# set path to our custom CMAKE scripts +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") + +# Create a "Release" build by default. +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING + "Select build type. Options are: 'Debug', 'Release', 'RelWithDebInfo' and 'MinSizeRel'." + FORCE + ) + message(STATUS "Set CMAKE_BUILD_TYPE to default '${CMAKE_BUILD_TYPE}'.") +endif(NOT CMAKE_BUILD_TYPE) + +# Do not allow an in-source-tree build, request an out-of-source-tree build. +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR "#Please build outside of the source tree!\n + Make a separate folder for building and run CMake there:\n + mkdir _build; cd _build; cmake ..\n + Before that, cleanup:\nrm -rf CMakeCache.txt CMakeFiles") endif() -# add src subdirectory to project -add_subdirectory(tutorial_1) \ No newline at end of file +# Disable in-source builds and modifications to the source tree. +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) + +#------------------------------------------------------------------------------ +# Display Status +#------------------------------------------------------------------------------ + +message("") +message("== Building ${PROJECT_NAME} using build type '${CMAKE_BUILD_TYPE}'.") +message(STATUS " Source directory is '${PROJECT_SOURCE_DIR}'.") +message(STATUS " Build directory is '${PROJECT_BINARY_DIR}'.") +message(STATUS " Installation path is '${CMAKE_INSTALL_PREFIX}' (set -DCMAKE_INSTALL_PREFIX= to change).") +message(STATUS " CXX Compiler Flags: '${CMAKE_CXX_FLAGS}'.") +message(STATUS " Dependencies folder: '${PROJECT_SOURCE_DIR}/../dependencies'.") +message("") + +#------------------------------------------------------------------------------ +# Compiler Options +#------------------------------------------------------------------------------ + +if(WIN32) + + if(MSVC) + + # ensure we use minimal "windows.h" lib without the crazy min max macros + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"WIN32_LEAN_AND_MEAN\"") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"") + + # disable SAFESEH - to avoid "LNK2026: module unsafe" on "OpenAL32.lib" + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SAFESEH:NO\"") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") + SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") + + endif(MSVC) + +endif(WIN32) + +#------------------------------------------------------------------------------ +# Find Dependencies - Windows +#------------------------------------------------------------------------------ + +# Tell CMake where to search for binaries (dlls), includes and libs on Windows +if(WIN32) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} + "${PROJECT_SOURCE_DIR}/../dependencies/bin" + "${PROJECT_SOURCE_DIR}/../dependencies/include" + "${PROJECT_SOURCE_DIR}/../dependencies/include/SDL2" + "${PROJECT_SOURCE_DIR}/../dependencies/include/OpenAL" + "${PROJECT_SOURCE_DIR}/../dependencies/lib/x86" + "${PROJECT_SOURCE_DIR}/../dependencies/lib" + "${PROJECT_SOURCE_DIR}/../dependencies/lib/boost" + ) + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_PREFIX_PATH}) +endif(WIN32) + +#------------------------------------------------------------------------------ +# Configure Boost +#------------------------------------------------------------------------------ + +add_definitionS(-DBOOST_ALL_NO_LIB) + +# use static libs +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) + +#------------------------------------------------------------------------------ +# Add Subdirectories for Tutorials +#------------------------------------------------------------------------------ + +add_subdirectory(tutorial_1) + +#------------------------------------------------------------------------------ +# Package Tutorials +#------------------------------------------------------------------------------ + +# include system runtimes (e.g. msvcp140.dll) into "/bin" folder +# how can i change/remove the "bin" suffix to install into ? +include(InstallRequiredSystemLibraries) + +# set package type depending on OS +#if(WIN32) +# set(CPACK_GENERATOR ${CPACK_GENERATOR} ZIP) +#elseif(APPLE) +# set(CPACK_GENERATOR ${CPACK_GENERATOR} DragNDrop) +#else() +# set(CPACK_GENERATOR ${CPACK_GENERATOR} TGZ) +#endif() + +#set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") + +# tell CPack all of the components to install.. +#set(CPACK_COMPONENTS_ALL executable libraries) + +#set(CPACK_MONOLITHIC_INSTALL on) + +# tell cpack to strip debug symbols from files +#set(CPACK_STRIP_FILES 1) + +# this must be the last call +#include(CPack) \ No newline at end of file diff --git a/src/CopyExtDlls.cmake b/src/CopyExtDlls.cmake deleted file mode 100644 index a0ed089..0000000 --- a/src/CopyExtDlls.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# used to copy external dlls to the proper location on windows -IF (WIN32) - FILE(GLOB DLLS ${EXT_DLL_DIR}/*.dll) - FILE(COPY ${DLLS} DESTINATION ${DEST_DIR}) -ENDIF() \ No newline at end of file diff --git a/src/tutorial_1/CMakeLists.txt b/src/tutorial_1/CMakeLists.txt old mode 100644 new mode 100755 index 9f58bdf..06906f1 --- a/src/tutorial_1/CMakeLists.txt +++ b/src/tutorial_1/CMakeLists.txt @@ -1,84 +1,110 @@ -cmake_minimum_required (VERSION 2.6) +#------------------------------------------------------------------------------ +# Fifengine C++ Tutorial 1 +#------------------------------------------------------------------------------ -FILE(GLOB TUTORIAL1_SRC *.cpp *.h) +project(Tutorial1) + +cmake_minimum_required (VERSION 3.0) + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules) + +file(GLOB TUTORIAL1_SRC *.cpp *.h) add_executable(Tutorial1 ${TUTORIAL1_SRC}) + set_target_properties(Tutorial1 PROPERTIES DEBUG_POSTFIX "_d") -add_library(fife STATIC IMPORTED) +if(APPLE) + find_package(Xcursor REQUIRED) + target_link_libraries(Tutorial1 ${XCURSOR_LIBRARY}) + include(${XCURSOR_INCLUDE_DIR}) +endif() if(UNIX) - INCLUDE_DIRECTORIES(/usr/local/include/fife/core) - set_property(TARGET fife PROPERTY IMPORTED_LOCATION /usr/local/lib/libfife.a) - FIND_PACKAGE(X11 REQUIRED) - TARGET_LINK_LIBRARIES(Tutorial1 ${X11_LIBRARY}) - TARGET_LINK_LIBRARIES(Tutorial1 Xcursor) - TARGET_LINK_LIBRARIES(Tutorial1 fifechan) - TARGET_LINK_LIBRARIES(Tutorial1 fifechan_sdl) - TARGET_LINK_LIBRARIES(Tutorial1 fifechan_opengl) - TARGET_LINK_LIBRARIES(Tutorial1 vorbis) -elseif(WIN32) - add_library(fifechan STATIC IMPORTED) - add_library(fifechan_sdl STATIC IMPORTED) - add_library(fifechan_opengl STATIC IMPORTED) - add_library(vorbis_static STATIC IMPORTED) - add_library(vorbisfile_static STATIC IMPORTED) - add_library(ogg_static STATIC IMPORTED) - INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../../engine/core - ${PROJECT_SOURCE_DIR}/../../build/win32/includes/libfifechan) - FIND_LIBRARY(FIFE_LIB fife) - set_property(TARGET fife PROPERTY IMPORTED_LOCATION ${FIFE_LIB}) - FIND_LIBRARY(FIFECHAN fifechan) - set_property(TARGET fifechan PROPERTY IMPORTED_LOCATION ${FIFECHAN}) - FIND_LIBRARY(FIFECHAN_SDL fifechan_sdl) - set_property(TARGET fifechan_sdl PROPERTY IMPORTED_LOCATION ${FIFECHAN_SDL}) - FIND_LIBRARY(FIFECHAN_OPENGL fifechan_opengl) - set_property(TARGET fifechan_opengl PROPERTY IMPORTED_LOCATION ${FIFECHAN_OPENGL}) - TARGET_LINK_LIBRARIES(Tutorial1 fifechan fifechan_sdl fifechan_opengl) - FIND_LIBRARY(VORBIS vorbis_static) - set_property(TARGET vorbis_static PROPERTY IMPORTED_LOCATION ${VORBIS}) - TARGET_LINK_LIBRARIES(Tutorial1 vorbis_static) - FIND_LIBRARY(VORBIS_FILE vorbisfile_static) - set_property(TARGET vorbisfile_static PROPERTY IMPORTED_LOCATION ${VORBIS_FILE}) - TARGET_LINK_LIBRARIES(Tutorial1 vorbisfile_static) - FIND_LIBRARY(OGG ogg_static) - set_property(TARGET ogg_static PROPERTY IMPORTED_LOCATION ${OGG}) - TARGET_LINK_LIBRARIES(Tutorial1 ogg_static) - - ADD_CUSTOM_COMMAND(TARGET Tutorial1 POST_BUILD - COMMAND ${CMAKE_COMMAND} - -DEXT_DLL_DIR="${EXT_DLL_DIR}" - -DDEST_DIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}" - -P "${CMAKE_SOURCE_DIR}/CopyExtDlls.cmake" - COMMENT "copying dlls..." - ) + find_package(X11 REQUIRED) + target_link_libraries(Tutorial1 ${X11_LIBRARY}) + target_link_libraries(Tutorial1 Xcursor) endif() -FIND_PACKAGE(SDL REQUIRED) -FIND_PACKAGE(SDL_image REQUIRED) -FIND_PACKAGE(SDL_ttf REQUIRED) -FIND_PACKAGE(OpenAL REQUIRED) -FIND_PACKAGE(OpenGL REQUIRED) -FIND_PACKAGE(Boost 1.47.0 COMPONENTS system filesystem regex REQUIRED) -FIND_PACKAGE(PNG REQUIRED) -FIND_PACKAGE(ZLIB REQUIRED) - -INCLUDE_DIRECTORIES( - ${SDL_INCLUDE_DIR} - ${SDL_IMAGE_INCLUDE_DIR} - ${SDL_TTF_INCLUDE_DIR} - ${PNG_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} - ${Boost_INCLUDE_DIR} +find_package(Fife REQUIRED) +find_package(FifeChan COMPONENTS opengl sdl REQUIRED) +find_package(Boost 1.33.1 COMPONENTS system filesystem regex) +find_package(Vorbis REQUIRED) +find_package(ZLIB REQUIRED) +find_package(PNG REQUIRED) +find_package(Ogg REQUIRED) +find_package(SDL2 REQUIRED) +find_package(SDL2_image REQUIRED) +find_package(SDL2_ttf REQUIRED) +find_package(OpenAL REQUIRED) +find_package(OpenGL REQUIRED) +find_package(TinyXML REQUIRED) + +include_directories( + ${ZLIB_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} + ${OGG_INCLUDE_DIR} + ${PNG_INCLUDE_DIR} + ${SDL2_IMAGE_INCLUDE_DIR} + ${SDL2_INCLUDE_DIR} + ${SDL2_TTF_INCLUDE_DIR} + ${VORBIS_INCLUDE_DIR} + ${FIFE_INCLUDE_DIR} + ${FIFECHAN_INCLUDE_DIR} ) -TARGET_LINK_LIBRARIES(Tutorial1 fife) -TARGET_LINK_LIBRARIES(Tutorial1 ${SDL_LIBRARY}) -TARGET_LINK_LIBRARIES(Tutorial1 ${SDLIMAGE_LIBRARY}) -TARGET_LINK_LIBRARIES(Tutorial1 ${SDLTTF_LIBRARY}) -TARGET_LINK_LIBRARIES(Tutorial1 ${PNG_LIBRARY}) -TARGET_LINK_LIBRARIES(Tutorial1 ${ZLIB_LIBRARIES}) -TARGET_LINK_LIBRARIES(Tutorial1 ${OPENGL_LIBRARY}) -TARGET_LINK_LIBRARIES(Tutorial1 ${Boost_LIBRARIES}) -TARGET_LINK_LIBRARIES(Tutorial1 ${VORBIS_LIBRARIES}) -TARGET_LINK_LIBRARIES(Tutorial1 ${OPENAL_LIBRARY}) +target_link_libraries(Tutorial1 ${ZLIB_LIBRARIES}) +target_link_libraries(Tutorial1 ${Boost_LIBRARIES}) +target_link_libraries(Tutorial1 ${OPENAL_LIBRARY}) +target_link_libraries(Tutorial1 ${OPENGL_LIBRARY}) +target_link_libraries(Tutorial1 ${PNG_LIBRARIES}) +target_link_libraries(Tutorial1 ${SDL2_LIBRARY}) +target_link_libraries(Tutorial1 ${SDL2_IMAGE_LIBRARIES}) +target_link_libraries(Tutorial1 ${SDL2_TTF_LIBRARIES}) +target_link_libraries(Tutorial1 ${TinyXML_LIBRARIES}) +target_link_libraries(Tutorial1 ${OGG_LIBRARIES}) +target_link_libraries(Tutorial1 ${VORBIS_LIBRARIES}) +target_link_libraries(Tutorial1 ${VORBIS_LIBRARY}) +target_link_libraries(Tutorial1 ${VORBISFILE_LIBRARY}) +target_link_libraries(Tutorial1 ${FIFECHAN_LIBRARIES}) +target_link_libraries(Tutorial1 ${FIFE_LIBRARIES}) + +#------------------------------------------------------------------------------ +# Install Tutorial 1 +#------------------------------------------------------------------------------ + +# install the binary/exe into the subfolder "Tutorial1" +install(TARGETS Tutorial1 + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME} + COMPONENT executable +) + +if(WIN32) + + # set paths to executables + set(APP ${CMAKE_INSTALL_PREFIX}/Tutorial1/Tutorial1${CMAKE_EXECUTABLE_SUFFIX}) + + # set paths to dependencies + set(DIRS ${PROJECT_SOURCE_DIR}/../../dependencies/bin + ${PROJECT_SOURCE_DIR}/../../dependencies/lib + ${PROJECT_SOURCE_DIR}/../../dependencies/lib/x86 + ) + + # copy all libraries to the binary folder + # by calling fixup_bundle, when TARGET INSTALL is executed + install(CODE " + include(BundleUtilities) + fixup_bundle(\"${APP}\" \"\" \"${DIRS}\") + " + COMPONENT libraries + ) + +endif() + +#------------------------------------------------------------------------------ +# Copy assets +#------------------------------------------------------------------------------ + +add_custom_command(TARGET Tutorial1 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/../assets $/assets) diff --git a/src/tutorial_1/Game.cpp b/src/tutorial_1/Game.cpp old mode 100644 new mode 100755 index 8525c93..151eb19 --- a/src/tutorial_1/Game.cpp +++ b/src/tutorial_1/Game.cpp @@ -37,14 +37,11 @@ namespace fs = boost::filesystem; //! //!*************************************************************** Game::Game() -: m_map(0), m_mainCamera(0), m_player(0), m_mouseListener(0), m_keyListener(0), m_quit(false) +: m_map(0), m_mainCamera(0), m_mouseListener(0), m_keyListener(0), m_player(0), m_quit(false) { // create the engine m_engine = new FIFE::Engine(); - // engine must be created - assert(NULL != m_engine); - // create view controller m_viewController = new ViewController(); @@ -150,7 +147,7 @@ void Game::Run() // this functionality should be part of the engine // it will be migrated there soon, so the client // does not have to call SDL directly - SDL_WM_SetCaption(windowTitle.c_str(), 0); + SDL_SetWindowTitle(m_engine->getRenderBackend()->getWindow(), windowTitle.c_str()); // update the last time fps was calculated lastTime = m_engine->getTimeManager()->getTime(); @@ -219,7 +216,7 @@ void Game::InitSettings() FIFE::EngineSettings& settings = m_engine->getSettings(); // get the path to the font we are going to use - fs::path defaultFontPath("../../assets/fonts/FreeSans.ttf"); + fs::path defaultFontPath("assets/fonts/FreeSans.ttf"); // change the engine settings to suite our game settings.setRenderBackend("OpenGL"); @@ -261,7 +258,7 @@ void Game::CreateMap() FIFE::MapLoader* mapLoader = new FIFE::MapLoader(m_engine->getModel(), m_engine->getVFS(), m_engine->getImageManager(), m_engine->getRenderBackend()); - fs::path mapPath("../../assets/maps/shrine.xml"); + fs::path mapPath("assets/maps/shrine.xml"); if (mapLoader) { // load the map @@ -366,4 +363,4 @@ void Game::InitView() } } } -} \ No newline at end of file +} diff --git a/src/tutorial_1/KeyListener.cpp b/src/tutorial_1/KeyListener.cpp index 7d2bb90..f2d7d2c 100644 --- a/src/tutorial_1/KeyListener.cpp +++ b/src/tutorial_1/KeyListener.cpp @@ -4,8 +4,8 @@ //***************************************************************************** #include -#include "eventchannel/key/ec_keyevent.h" -#include "eventchannel/key/ec_key.h" +#include "eventchannel/key/keyevent.h" +#include "eventchannel/key/key.h" #include "Game.h" #include "ViewController.h" diff --git a/src/tutorial_1/KeyListener.h b/src/tutorial_1/KeyListener.h index 94e75bd..ee3799f 100644 --- a/src/tutorial_1/KeyListener.h +++ b/src/tutorial_1/KeyListener.h @@ -5,7 +5,7 @@ #ifndef KEY_LISTENER_H_ #define KEY_LISTENER_H_ -#include "eventchannel/key/ec_ikeylistener.h" +#include "eventchannel/key/ikeylistener.h" namespace FIFE { diff --git a/src/tutorial_1/MouseListener.cpp b/src/tutorial_1/MouseListener.cpp index 1bf2f54..0831be5 100644 --- a/src/tutorial_1/MouseListener.cpp +++ b/src/tutorial_1/MouseListener.cpp @@ -6,7 +6,7 @@ #include // fife includes -#include "eventchannel/mouse/ec_mouseevent.h" +#include "eventchannel/mouse/mouseevent.h" #include "model/metamodel/modelcoords.h" #include "model/structures/location.h" #include "util/structures/rect.h" @@ -193,6 +193,38 @@ void MouseListener::mouseWheelMovedDown(FIFE::MouseEvent& evt) SetPreviousMouseEvent(evt.getType()); } +//!*************************************************************** +//! @details: +//! overridden from base class +//! +//! @param[in]: evt +//! signaled event +//! +//! @return: +//! void +//! +//!*************************************************************** +void MouseListener::mouseWheelMovedRight(FIFE::MouseEvent& evt) +{ + SetPreviousMouseEvent(evt.getType()); +} + +//!*************************************************************** +//! @details: +//! overridden from base class +//! +//! @param[in]: evt +//! signaled event +//! +//! @return: +//! void +//! +//!*************************************************************** +void MouseListener::mouseWheelMovedLeft(FIFE::MouseEvent& evt) +{ + SetPreviousMouseEvent(evt.getType()); +} + //!*************************************************************** //! @details: //! overridden from base class @@ -239,11 +271,11 @@ void MouseListener::mouseDragged(FIFE::MouseEvent& evt) FIFE::ScreenPoint delta(m_dragX - currX, m_dragY - currY); // get the current camera location - FIFE::ScreenPoint cameraScreenCoords = m_camera->toScreenCoordinates(m_camera->getLocationRef().getMapCoordinates()); + FIFE::ScreenPoint cameraScreenCoords = m_camera->toScreenCoordinates(m_camera->getLocation().getMapCoordinates()); cameraScreenCoords += delta; // set the new coordinates - FIFE::Location camLocation(m_camera->getLocationRef()); + FIFE::Location camLocation(m_camera->getLocation()); FIFE::ExactModelCoordinate mapCoords = m_camera->toMapCoordinates(cameraScreenCoords, false); mapCoords.z = 0.0; camLocation.setMapCoordinates(mapCoords); diff --git a/src/tutorial_1/MouseListener.h b/src/tutorial_1/MouseListener.h index 384d56a..07e2de3 100644 --- a/src/tutorial_1/MouseListener.h +++ b/src/tutorial_1/MouseListener.h @@ -5,8 +5,8 @@ #ifndef MOUSE_LISTENER_H_ #define MOUSE_LISTENER_H_ -#include "eventchannel/mouse/ec_imouselistener.h" -#include "eventchannel/mouse/ec_mouseevent.h" +#include "eventchannel/mouse/imouselistener.h" +#include "eventchannel/mouse/mouseevent.h" #include "ScreenScroller.h" @@ -36,6 +36,8 @@ class MouseListener : public FIFE::IMouseListener virtual void mouseClicked(FIFE::MouseEvent& evt); virtual void mouseWheelMovedUp(FIFE::MouseEvent& evt); virtual void mouseWheelMovedDown(FIFE::MouseEvent& evt); + virtual void mouseWheelMovedRight(FIFE::MouseEvent& evt); + virtual void mouseWheelMovedLeft(FIFE::MouseEvent& evt); virtual void mouseMoved(FIFE::MouseEvent& evt); virtual void mouseDragged(FIFE::MouseEvent& evt); diff --git a/src/tutorial_1/ReadMe.txt b/src/tutorial_1/ReadMe.txt deleted file mode 100644 index 2ab0f50..0000000 --- a/src/tutorial_1/ReadMe.txt +++ /dev/null @@ -1,31 +0,0 @@ - -Fife tutorial 1 - -This is the first tutorial based on the FIFE engine. - -The tutorial will go through the following: - 1) Engine initialization and setup - 2) Setting up user input - 3) Loading a map - 4) Manipulating the camera through input keys and mouse - 5) Moving characters on screen - 6) Auto screen scrolling based on mouse cursor position - -Directory layout -All code for this tutorial can be found in the src directory. -The art assets used for this demo are located in the assets directory. -The visual studio 2008 solution can be found in the build/msvc2008 directory. - -Build -Place this tutorial in the /demos folder. To build open the -visual studio solution in the build/msvc2008 directory and run the build -command. If you do not place this in the demos directory of fife you will -need to modify the project properties to correctly point to where fife is -installed. - -Dependencies -This package requires the FIFE engine release 0.3.1 (http://fifengine.net) -The latest win32 installer can be found here (includes all dependencies): - http://sourceforge.net/projects/fife/files/active/packages/FIFE-0.3.1_installer_win32.exe/download -The FIFE source code can be found here: - http://sourceforge.net/projects/fife/files/active/src/fife-0.3.1.tar.gz/download diff --git a/src/tutorial_1/ScreenScroller.cpp b/src/tutorial_1/ScreenScroller.cpp old mode 100644 new mode 100755 index afa676c..19e49dd --- a/src/tutorial_1/ScreenScroller.cpp +++ b/src/tutorial_1/ScreenScroller.cpp @@ -6,7 +6,7 @@ #include "util/time/timemanager.h" #include "eventchannel/eventmanager.h" -#include "eventchannel/command/ec_command.h" +#include "eventchannel/command/command.h" //!*************************************************************** //! @details: @@ -63,7 +63,7 @@ ScreenScroller::~ScreenScroller() //!*************************************************************** void ScreenScroller::evaluateLocation() { - m_scrollCoords = m_camera->toScreenCoordinates(m_camera->getLocationRef().getMapCoordinates()); + m_scrollCoords = m_camera->toScreenCoordinates(m_camera->getLocation().getMapCoordinates()); m_shouldScroll = false; @@ -173,7 +173,7 @@ void ScreenScroller::updateEvent(uint32_t time) { if (m_shouldScroll) { - FIFE::Location camLocation(m_camera->getLocationRef()); + FIFE::Location camLocation(m_camera->getLocation()); FIFE::ExactModelCoordinate mapCoords = m_camera->toMapCoordinates(m_scrollCoords, false); mapCoords.z = 0.0; camLocation.setMapCoordinates(mapCoords); @@ -198,14 +198,13 @@ void ScreenScroller::updateEvent(uint32_t time) //! bool //! //!*************************************************************** + bool ScreenScroller::onSdlEvent(SDL_Event& evt) { // if it is a mouse focus event and we have lost focus // then we need to unregister for events until // we have regained focus - if (evt.type == SDL_ACTIVEEVENT - && (evt.active.state & SDL_APPMOUSEFOCUS) - && !evt.active.gain) + if (evt.type == SDL_WINDOWEVENT && evt.window.event == SDL_WINDOWEVENT_LEAVE) { unregisterEvent(); return true; diff --git a/src/tutorial_1/ScreenScroller.h b/src/tutorial_1/ScreenScroller.h index 2837053..4b2abe0 100644 --- a/src/tutorial_1/ScreenScroller.h +++ b/src/tutorial_1/ScreenScroller.h @@ -7,8 +7,8 @@ #include "util/base/fife_stdint.h" #include "util/time/timeevent.h" -#include "eventchannel/command/ec_icommandlistener.h" -#include "eventchannel/sdl/ec_isdleventlistener.h" +#include "eventchannel/command/icommandlistener.h" +#include "eventchannel/sdl/isdleventlistener.h" #include "view/camera.h" namespace FIFE