Font interface for scripts
This commit is contained in:
parent
d6088eeac2
commit
e566155570
@ -34,6 +34,7 @@
|
||||
E80B28DB17B39D160056179E /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = E80B28D817B39D160056179E /* unzip.c */; };
|
||||
E80B28DE17B39EEF0056179E /* ZipFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E80B28DC17B39EEE0056179E /* ZipFileSystem.cpp */; };
|
||||
E80B28E117B4FDDA0056179E /* DynamicMemoryStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E80B28DF17B4FDD40056179E /* DynamicMemoryStream.cpp */; };
|
||||
E81CE4A6183F7A3000F22685 /* IFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E81CE4A4183F7A3000F22685 /* IFont.cpp */; };
|
||||
E834F55017942C43004EBE88 /* Grenade.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E834F54E17942C43004EBE88 /* Grenade.cpp */; };
|
||||
E834F55317944779004EBE88 /* NetClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E834F55117944778004EBE88 /* NetClient.cpp */; };
|
||||
E834F5561794BBD4004EBE88 /* Debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E834F5541794BBD4004EBE88 /* Debug.cpp */; };
|
||||
@ -316,6 +317,7 @@
|
||||
E80B28DD17B39EEF0056179E /* ZipFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZipFileSystem.h; sourceTree = "<group>"; };
|
||||
E80B28DF17B4FDD40056179E /* DynamicMemoryStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicMemoryStream.cpp; sourceTree = "<group>"; };
|
||||
E80B28E017B4FDD70056179E /* DynamicMemoryStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicMemoryStream.h; sourceTree = "<group>"; };
|
||||
E81CE4A4183F7A3000F22685 /* IFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IFont.cpp; sourceTree = "<group>"; };
|
||||
E834F54E17942C43004EBE88 /* Grenade.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Grenade.cpp; sourceTree = "<group>"; };
|
||||
E834F54F17942C43004EBE88 /* Grenade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grenade.h; sourceTree = "<group>"; };
|
||||
E834F55117944778004EBE88 /* NetClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetClient.cpp; sourceTree = "<group>"; };
|
||||
@ -1162,6 +1164,7 @@
|
||||
E8B6B74517EA0F1E00E35523 /* IGrenadeSkin.h */,
|
||||
E8B6B74717EA12E100E35523 /* IWeaponSkin.cpp */,
|
||||
E8B6B74817EA12E500E35523 /* IWeaponSkin.h */,
|
||||
E81CE4A4183F7A3000F22685 /* IFont.cpp */,
|
||||
);
|
||||
name = ScriptBindings;
|
||||
path = Sources/ScriptBindings;
|
||||
@ -1818,6 +1821,7 @@
|
||||
E8B6B69217DE27B500E35523 /* as_callfunc.cpp in Sources */,
|
||||
E8B6B6A117DE27B500E35523 /* as_compiler.cpp in Sources */,
|
||||
E8B6B6A217DE27B500E35523 /* as_configgroup.cpp in Sources */,
|
||||
E81CE4A6183F7A3000F22685 /* IFont.cpp in Sources */,
|
||||
E8B6B6A317DE27B500E35523 /* as_context.cpp in Sources */,
|
||||
E8B6B6A417DE27B500E35523 /* as_datatype.cpp in Sources */,
|
||||
E8B6B6A517DE27B500E35523 /* as_gc.cpp in Sources */,
|
||||
|
@ -313,9 +313,9 @@ namespace spades {
|
||||
delete paletteView;
|
||||
delete centerMessageView;
|
||||
delete hurtRingView;
|
||||
delete designFont;
|
||||
delete textFont;
|
||||
delete bigTextFont;
|
||||
designFont->Release();
|
||||
textFont->Release();
|
||||
bigTextFont->Release();
|
||||
}
|
||||
|
||||
bool Client::WantsToBeClosed() {
|
||||
|
@ -20,13 +20,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Core/Math.h"
|
||||
#include <Core/Math.h>
|
||||
#include <Core/RefCountedObject.h>
|
||||
|
||||
namespace spades {
|
||||
namespace client{
|
||||
class IFont {
|
||||
public:
|
||||
class IFont: public RefCountedObject {
|
||||
protected:
|
||||
virtual ~IFont();
|
||||
public:
|
||||
|
||||
virtual Vector2 Measure(const std::string&) = 0;
|
||||
virtual void Draw(const std::string&, Vector2 offset, float scale, Vector4 color) = 0;
|
||||
|
@ -45,13 +45,14 @@ namespace spades {
|
||||
int glyphHeight;
|
||||
std::vector<GlyphInfo> glyphs;
|
||||
float spaceWidth;
|
||||
protected:
|
||||
virtual ~Quake3Font();
|
||||
public:
|
||||
Quake3Font(IRenderer *,
|
||||
IImage *texture,
|
||||
const int *map,
|
||||
int glyphHeight,
|
||||
float spaceWidth);
|
||||
virtual ~Quake3Font();
|
||||
|
||||
virtual Vector2 Measure(const std::string&);
|
||||
virtual void Draw(const std::string&,
|
||||
|
80
Sources/ScriptBindings/IFont.cpp
Normal file
80
Sources/ScriptBindings/IFont.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright (c) 2013 yvt
|
||||
|
||||
This file is part of OpenSpades.
|
||||
|
||||
OpenSpades is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenSpades is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "ScriptManager.h"
|
||||
#include <Client/IFont.h>
|
||||
|
||||
namespace spades {
|
||||
class FontRegistrar: public ScriptObjectRegistrar {
|
||||
|
||||
|
||||
public:
|
||||
FontRegistrar():
|
||||
ScriptObjectRegistrar("Font") {}
|
||||
|
||||
virtual void Register(ScriptManager *manager, Phase phase) {
|
||||
asIScriptEngine *eng = manager->GetEngine();
|
||||
int r;
|
||||
eng->SetDefaultNamespace("spades");
|
||||
switch(phase){
|
||||
case PhaseObjectType:
|
||||
r = eng->RegisterObjectType("Font",
|
||||
0, asOBJ_REF);
|
||||
manager->CheckError(r);
|
||||
break;
|
||||
case PhaseObjectMember:
|
||||
r = eng->RegisterObjectBehaviour("Font",
|
||||
asBEHAVE_ADDREF,
|
||||
"void f()",
|
||||
asMETHOD(client::IFont, AddRef),
|
||||
asCALL_THISCALL);
|
||||
manager->CheckError(r);
|
||||
r = eng->RegisterObjectBehaviour("Font",
|
||||
asBEHAVE_RELEASE,
|
||||
"void f()",
|
||||
asMETHOD(client::IFont, Release),
|
||||
asCALL_THISCALL);
|
||||
manager->CheckError(r);
|
||||
r = eng->RegisterObjectMethod("Font",
|
||||
"Vector2 Measure(const string& in)",
|
||||
asMETHOD(client::IFont, Measure),
|
||||
asCALL_THISCALL);
|
||||
manager->CheckError(r);
|
||||
r = eng->RegisterObjectMethod("Font",
|
||||
"void Draw(const string& in, Vector2, float, Vector4)",
|
||||
asMETHOD(client::IFont, Draw),
|
||||
asCALL_THISCALL);
|
||||
manager->CheckError(r);
|
||||
r = eng->RegisterObjectMethod("Font",
|
||||
"void DrawShadow(const string& in, const Vector2& in, float, const Vector4& in)",
|
||||
asMETHOD(client::IFont, DrawShadow),
|
||||
asCALL_THISCALL);
|
||||
manager->CheckError(r);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static FontRegistrar registrar;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user