zoukankan      html  css  js  c++  java
  • MMORPG大型游戏设计与开发(客户端架构 part6 of vegine)

    客户端的变量模块部分主要是将一些常用可变的值集中管理,如窗口的大小,是否开启音乐,音量的大小等等。这些变量通常会应该到客户端的操作,一般来说变量改变的时候会调用一个回调进行处理。下面我们就看看该模块的常用方法吧。

    CODE

    文件system.h

    /**
     * PAP Engine ( -- )
     * $Id system.h
     * @link -- for the canonical source repository
     * @copyright Copyright (c) 2013-2014 viticm( viticm@126.com )
     * @license
     * @user viticm<viticm@126.com/viticm.ti@gmail.com>
     * @date 2014-3-19 16:27:01
     * @uses vengine variable system module
     */
    #ifndef VENGINE_VARIABLE_SYSTEM_H_
    #define VENGINE_VARIABLE_SYSTEM_H_
    
    #include "vengine/config.h"
    #include "vengine/kernel/node.h"
    #include "vengine/math/base.h"
    
    namespace vengine_variable {
    
    class VENGINE_API System : public vengine_kernel::Node {
    
    VENGINE_KERNEL_DECLARE_DYNAMIC(vengine_variable_System);
    
     public:
       //得到某个变量的值,如果不存在,则返回false
       virtual bool getvariable(const char* name, STRING& save) = 0;
       //设置某个变量的值,如果不存在,则首先创建
       virtual void setvariable(const char* name, 
                                const char* value, 
                                bool temp = true, 
                                bool fireevent = true) = 0;
    
       //设置某个变量的值,但并不马上生效, 下一次启动时才会生效
       virtual void setvariable_delay(const char* name, const char* value) = 0;
    
       /* 快速设置方法 */
       virtual void setint32(const char* name, 
                             int32_t value, 
                             bool temp = true) = 0;
       virtual void setuint32(const char* name, 
                              uint32_t value, 
                              bool temp = true) = 0;
       virtual void setfloat(const char* name, 
                             float value, 
                             bool temp = true) = 0;
       virtual void set_twofloat_vector(const char* name,
                                        float value1,
                                        float value2,
                                        bool temp = true) = 0;
    
       /* 快速获取方法 */
       virtual const STRING& getstring(const char* name, bool* have = NULL) = 0;
       virtual int32_t getint32(const char* name, bool* have = NULL) = 0;
       virtual uint32_t getuint32(const char* name, bool* have = NULL) = 0;
       virtual float getfloat(const char* name, bool* have = NULL) = 0;
       virtual vengine_math::base::twofloat_vector_t get_twofloat_vector(
           const char* name, bool* have = NULL) = 0;
       virtual void setvariable_default(const char* name, const char* value) = 0;
       virtual void load_privateconfig() = 0;
       virtual void getvariable_infile(const char* filename,  
                                       const char* title,
                                       const char* key,
                                       char* save,
                                       uint16_t size) = 0;
       virtual void setvariable_infile(const char* filename,
                                       const char* title,
                                       const char* key,
                                       const char* value) = 0;
       virtual void reset() = 0;
    
    };
    
    }; //namespace vengine_variable
    
    #endif //VENGINE_VARIABLE_SYSTEM_H_

    SIMPLE

      天龙八部的系统设置,也是采用该模式进行控制的。

      

    总结

      变量的设置和文件的读写有密切的关系,不知道大家是否还记得有关ini配置文件的操作,该部分的操作基本上是与它一致的。

  • 相关阅读:
    ObjectForScripting 注册
    取消mysql表中timestamp字段的自动更新
    分片与非分片使用聚合的区别
    java类加载过程
    springboot中使用solr8
    第四章
    获取cookie的两种方式和session共享解决方案
    剑指 Offer 57. 和为s的两个数字
    第三章
    第五章
  • 原文地址:https://www.cnblogs.com/lianyue/p/3898837.html
Copyright © 2011-2022 走看看