cegui的问题

来源:互联网 发布:软件售后服务流程 编辑:程序博客网 时间:2024/05/04 10:04

一直想做个小游戏的引擎,关于UI方面打算选用CEGUI。但是尝试在Mingw32下编译CEGUI没有成功,(唉还是自己的水平不行)。

那就在Windows下干吧:

Debug 模式下:链接

opengl32.lib
glu32.lib
sfml-system-s-d.lib
sfml-graphics-s-d.lib
sfml-window-s-d.lib
ceguibase_static_d.lib
silly_d.lib
openglguirenderer_static_d.lib
expat_d.lib
ceguifalagardwrbase_static_d.lib
ceguisillyimagecodec_static_d.lib
ceguiexpatparser_static_d.lib
sfml-main-d.lib
freetype_d.lib
winmm.lib
pcre_d.lib

Release模式下:

opengl32.lib
glu32.lib
sfml-system-s.lib
sfml-graphics-s.lib
sfml-window-s.lib
ceguibase_static.lib
silly.lib
openglguirenderer_static.lib
expat.lib
ceguifalagardwrbase_static.lib
ceguisillyimagecodec_static.lib
ceguiexpatparser_static.lib
sfml-main.lib
freetype.lib
winmm.lib
pcre_d.lib

有两个问题:第一个当我在Release模式下,试图连接Pcre.lib,竟然失败说是找不到pcre_free。怪!

第二是别忘了定义CEGUI_STATIC

 

 

 

 

(defun switch-source-file ()

  (interactive)

  (setq file-name (buffer-file-name))

  (if (string-match "//.cpp" file-name)

      (find-file (replace-regexp-in-string "//.cpp" "/.h" file-name)))

  (if (string-match "//.h" file-name)

      (find-file (replace-regexp-in-string "//.h" "/.cpp" file-name))))

(defun switch-source-file2 ()

  (interactive)

  (setq file-name (buffer-file-name))

  (if (string-match "//.cpp" file-name)

      (find-file (replace-regexp-in-string "//.cpp" "/.hpp" file-name)))

  (if (string-match "//.hpp" file-name)

      (find-file (replace-regexp-in-string "//.hpp" "/.cpp" file-name))))

(global-set-key [f11] 'switch-source-file)

(global-set-key [f12] 'switch-source-file)

 

 

#ifndef FND_GAME_ANIM_STATE_H
#define FND_GAME_ANIM_STATE_H
#include <string>
#include <sfml/graphics/rect.hpp>
#include "point.h"
namespace Fnd {
    class anim_group ;
    class anim_state {
    public:
        anim_state(anim_group* group, const std::string& init_anim) ;
        void update(float time_delta) ;
        const std::string& anim_name() const {return m_currentAnim ;}
        void change_anim(const std::string& anim_name) ;
        int anim_index() const {return m_currentIndex ;}
        bool is_looped() const {return m_isLooped ;}
        void set_loop(bool toloop = true) {m_isLooped = toloop;}
        const sf::IntRect& rect() const ;
        const point& center() const ;
        float current_anim_time() const {
            return m_AnimTime ;
        }
    private:
        anim_group* m_group ;
        std::string m_currentAnim ;
        int m_currentIndex ;
        bool m_isLooped ;
        float m_AnimTime ;
    } ;
}
#endif

 

 

 

 

#include <stdexcept>
#include "anim_state.h"
#include "anim_group.h"


namespace Fnd {
    void anim_state::update(float time_inteval) {
        if(!is_looped()) {
            if(anim_index() == m_group->length(m_currentAnim))
                return ;
        }
        m_AnimTime += time_inteval ;
        if(m_AnimTime >= m_group->anim_time(m_currentAnim, anim_index())) {
            m_AnimTime -= m_group->anim_time(m_currentAnim, anim_index()) ;
            if(anim_index() == m_group->length(m_currentAnim))
                m_currentIndex = 0 ;
            else m_currentIndex++ ;
        }
    }
    anim_state::anim_state(anim_group* group,
               const std::string& init_anim) :
        m_group(group),
        m_currentAnim(init_anim),
        m_currentIndex(0),
        m_isLooped(false) {
        if(!group->has_anim(init_anim)) throw std::runtime_error("bad anim") ;
    }

    const sf::IntRect& anim_state::rect() const {
        return m_group->rect(m_currentAnim, m_currentIndex) ;
    }

    const point& anim_state::center() const {
        return m_group->center(m_currentAnim, m_currentIndex) ;
    }

    void anim_state::change_anim(const std::string& anim_name) {
        if(!m_group->has_anim(anim_name)) throw std::runtime_error("bad anim") ;
        m_currentAnim = anim_name ;
        m_currentIndex = 0 ;
    }

   
}

 

#ifndef FND_GAME_ANIM_GROUP_H
#define FND_GAME_ANIM_GROUP_H
#include <vector>
#include <map>
#include <string>
#include <boost/tuple/tuple.hpp>
#include <sfml/graphics/rect.hpp>
#include "point.h"
namespace sf {
    class Image ;
}
namespace Fnd {
  
   class anim_group {
      enum {
         AG_TIME,
         AG_CENTER,
         AG_RECT,
      } ;
   public:
      bool has_anim(const std::string& name) const {
         return m_anims.count(name) == 1 ;
      }
      const sf::IntRect& rect(const std::string& name, int index)  {
         return boost::get<AG_RECT>(m_anims[name].second[index]);
      }
      size_t length(const std::string& name) {
         return m_anims[name].second.size() ;
      }
      float anim_time(const std::string& name, int index) {
         return boost::get<AG_TIME>(m_anims[name].second[index]) ;
      }
      const point& center(const std::string& name, int index) {
         return boost::get<AG_CENTER>(m_anims[name].second[index]) ;
      }
      bool bind_image(const std::string& name, sf::Image* img) {
         if(!has_anim(name)) return false ;
         m_anims[name].first = img ;
         return true ;
      }
      const sf::Image* const image(const std::string& name) {
         return m_anims[name].first ;
      }
      void push_back(const std::string& name, float time,
                     const point& pt,
                     const sf::IntRect& rect) {
         m_anims[name].second.push_back(boost::make_tuple(time,pt, rect)) ;
      }
      template<typename Iter>
      void bind_anim_list(const std::string& name,
                          Iter begin,
                          Iter end) {
         m_anims[name].second.assign(begin, end) ;
      }

      bool create_anim(const std::string& name) {
         if(has_anim(name)) return false ;
         m_anims[name] ;
         return true ;
      }
   public:
      typedef boost::tuple<float, point, sf::IntRect> anim_group_vector_value_type ;
      typedef std::vector<anim_group_vector_value_type> anim_group_vector_type ;
      typedef std::pair<sf::Image*, anim_group_vector_type> anim_group_value_type ;
      typedef std::map<std::string,anim_group_value_type> anim_group_map_type ;
   private:
      anim_group_map_type m_anims ;
                           
   } ;
}

#endif

 

#ifndef FND_GAME_POINT_H
#define FND_GAME_POINT_H
namespace Fnd {
struct point {
      int X ;
      int Y ;
      point(int x = 0, int y = 0) : X(x), Y(y) {}
   } ;
}
#endif

 

 

 

原创粉丝点击