You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.1 KiB
C++
110 lines
2.1 KiB
C++
//
|
|
// G A M E.O.N.E - LOW LEVEL LIB V1.0
|
|
// Copyright (C) 2001 LEVEL ONE ENTERTAINMENT,
|
|
// Licensed under the terms of LGPL.
|
|
//:---------------------------------------------------------------------------
|
|
//:Description
|
|
//
|
|
// FRAMEWORK game variables - a profile loader/saver
|
|
//
|
|
// CGamevars - container for CVariable
|
|
//
|
|
|
|
|
|
#ifndef _GAME_VARS_H
|
|
#define _GAME_VARS_H
|
|
|
|
#include "../lib_base.h"
|
|
#include <stdio.h>
|
|
|
|
typedef const char * VCHAR; // Zeicher auf einen Variablen Namen
|
|
|
|
|
|
/*
|
|
* Diese Klasse enthält zwei Strings.
|
|
* Den Namen einer Variablen und den Wert
|
|
*/
|
|
class CVariable
|
|
{
|
|
public:
|
|
CVariable();
|
|
CVariable(VCHAR name, bool wert );
|
|
CVariable(VCHAR name, int wert );
|
|
CVariable(VCHAR name, float wert );
|
|
CVariable(VCHAR name, VCHAR string);
|
|
~CVariable();
|
|
|
|
bool GetVarB(); // liefert Bool Wert
|
|
float GetVarF(); // liefert Float Wert
|
|
int GetVarI(); // liefert Integer Wert
|
|
VCHAR GetVarS(); // liefert String
|
|
|
|
void SetVar(bool wert);
|
|
void SetVar(float wert);
|
|
void SetVar(int i);
|
|
void SetVar(VCHAR string);
|
|
|
|
void SetName(VCHAR name); // Setzt Namen der Variablen
|
|
VCHAR GetName(); // Liefert Namen der Variablen
|
|
|
|
bool Save(FILE * fd);
|
|
bool Load(FILE * fd);
|
|
void Init();
|
|
|
|
static int CompareNames( const void * left, const void * right );
|
|
|
|
#define GW_NAME 64
|
|
char m_name[GW_NAME];
|
|
|
|
private:
|
|
char m_string[128];
|
|
float m_wert;
|
|
int m_bool;
|
|
|
|
#define GW_CRYPT true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
/*
|
|
* Containerklasse für CVariablen
|
|
*/
|
|
class CGamevars
|
|
{
|
|
public:
|
|
CGamevars();
|
|
CGamevars(VCHAR ufilename);
|
|
virtual ~CGamevars();
|
|
|
|
bool GetVarB(VCHAR name,bool defwert);
|
|
float GetVarF(VCHAR name,float defwert);
|
|
int GetVarI(VCHAR name,int defwert);
|
|
VCHAR GetVarS(VCHAR name,VCHAR defwert);
|
|
|
|
void SetVar(VCHAR name, float wert );
|
|
void SetVar(VCHAR name, VCHAR string );
|
|
void SetVar(VCHAR name, bool wert );
|
|
|
|
void SetVarB(VCHAR name, bool wert );
|
|
void SetVarF(VCHAR name, float wert );
|
|
void SetVarI(VCHAR name, int wert );
|
|
void SetVarS(VCHAR name, VCHAR string );
|
|
|
|
void SaveVars(VCHAR filename);
|
|
void LoadVars(VCHAR filename);
|
|
|
|
void Clear();
|
|
|
|
private:
|
|
queue<CVariable> m_vars;
|
|
char m_filename[128];
|
|
bool m_changed;
|
|
|
|
};
|
|
|
|
#endif // _GAME_VARS_H
|
|
|
|
|