MMORPG大型游戏设计与开发(客户端架构 part6 of vegine)

时间:2023-03-09 00:59:14
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) = ;
//设置某个变量的值,如果不存在,则首先创建
virtual void setvariable(const char* name,
const char* value,
bool temp = true,
bool fireevent = true) = ; //设置某个变量的值,但并不马上生效, 下一次启动时才会生效
virtual void setvariable_delay(const char* name, const char* value) = ; /* 快速设置方法 */
virtual void setint32(const char* name,
int32_t value,
bool temp = true) = ;
virtual void setuint32(const char* name,
uint32_t value,
bool temp = true) = ;
virtual void setfloat(const char* name,
float value,
bool temp = true) = ;
virtual void set_twofloat_vector(const char* name,
float value1,
float value2,
bool temp = true) = ; /* 快速获取方法 */
virtual const STRING& getstring(const char* name, bool* have = NULL) = ;
virtual int32_t getint32(const char* name, bool* have = NULL) = ;
virtual uint32_t getuint32(const char* name, bool* have = NULL) = ;
virtual float getfloat(const char* name, bool* have = NULL) = ;
virtual vengine_math::base::twofloat_vector_t get_twofloat_vector(
const char* name, bool* have = NULL) = ;
virtual void setvariable_default(const char* name, const char* value) = ;
virtual void load_privateconfig() = ;
virtual void getvariable_infile(const char* filename,
const char* title,
const char* key,
char* save,
uint16_t size) = ;
virtual void setvariable_infile(const char* filename,
const char* title,
const char* key,
const char* value) = ;
virtual void reset() = ; }; }; //namespace vengine_variable #endif //VENGINE_VARIABLE_SYSTEM_H_

SIMPLE

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

MMORPG大型游戏设计与开发(客户端架构 part6 of vegine)

总结

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