Skip to content
Snippets Groups Projects
Commit 6b2573f9 authored by dg's avatar dg
Browse files

fonts

git-svn-id: http://svn.net-core.org/repos/t-engine4@8 51575b47-30f0-44d4-a5cc-537603b46e54
parent db23ba46
No related branches found
No related tags found
No related merge requests found
Showing
with 607 additions and 77 deletions
File added
......@@ -7,11 +7,12 @@ module(..., package.seeall, class.inherit(Entity))
function _M:init(t)
t = t or {}
self.name = t.name
self.energy = { value=0, mod=1 }
Entity.init(self, t)
end
function _M:move(map, x, y)
if map:checkAllEntity(x, y, "block_move") then return end
if map:checkAllEntity(x, y, "block_move", self) then return true end
if self.x and self.y then
map:remove(self.x, self.y, Map.ACTOR)
......@@ -22,4 +23,6 @@ function _M:move(map, x, y)
if y >= map.h then y = map.h - 1 end
self.x, self.y = x, y
map(x, y, Map.ACTOR, self)
return true
end
......@@ -28,7 +28,7 @@ function _M:cloned()
end
function _M:check(prop, ...)
if type(self[prop]) == "function" then return self[prop](...)
if type(self[prop]) == "function" then return self[prop](self, ...)
else return self[prop]
end
end
......@@ -11,7 +11,14 @@ function _M:setLevel(level)
end
function _M:setCurrent()
core.game.set_current_gametick(self)
core.game.set_current_game(self)
end
function _M:display()
if self.level and self.level.map then
local s = self.level.map:display()
if s then s:toScreen(0, 0) end
end
end
-- This is the "main game loop", do something here
......
require "engine.class"
require "engine.Game"
module(..., package.seeall, class.inherit(engine.Game))
function _M:init(keyhandler, energy_to_act, energy_per_tick)
self.energy_to_act, self.energy_per_tick = energy_to_act, energy_per_tick
engine.Game.init(self, keyhandler)
end
function _M:tick()
engine.Game.tick(self)
-- Give some energy to entities
for uid, e in pairs(self.level.entities) do
if e.energy and e.energy.value < self.energy_to_act then
e.energy.value = (e.energy.value or 0) + self.energy_per_tick * (e.energy.mod or 1)
-- print(e.uid, e.energy.value)
if e.energy.value >= self.energy_to_act and e.act then
e:act(self)
end
end
end
end
require "engine.class"
require "engine.GameEnergyBased"
module(..., package.seeall, class.inherit(engine.GameEnergyBased))
function _M:init(keyhandler, energy_to_act, energy_per_tick)
self.paused = false
engine.GameEnergyBased.init(self, keyhandler, energy_to_act, energy_per_tick)
end
function _M:tick()
while not self.paused do
engine.GameEnergyBased.tick(self)
end
end
......@@ -36,3 +36,14 @@ function _M:addCommand(sym, mods, fct)
self.commands[sym][table.concat(mods,',')] = fct
end
end
function _M:addCommands(t)
for k, e in pairs(t) do
if type(k) == "string" then
self:addCommand(k, e)
elseif type(k) == "table" then
local sym = table.remove(k, 1)
self:addCommand(sym, k, e)
end
end
end
......@@ -6,10 +6,6 @@ function _M:init(map)
self.entities = {}
end
function _M:activate()
self.map:setCurrent()
end
function _M:addEntity(e)
if self.entities[e.uid] then error("Entity "..e.uid.." already present on the level") end
self.entities[e.uid] = e
......
require "engine.class"
module(..., package.seeall, class.make)
function _M:init(w, h, max, fontname, fontsize, color)
self.color = color or {255,255,255}
self.w, self.h = w, h
self.font = core.display.newFont(fontname or "/data/font/Vera.ttf", fontsize or 10)
self.surface = core.display.newSurface(w, h)
self.log = {}
getmetatable(self).__call = _M.call
self.max = max or 400
self.changed = true
end
function _M:call(str, ...)
table.insert(self.log, 1, str:format(...))
while #self.log > self.max do
table.remove(self.log)
end
self.changed = true
end
function _M:empty()
self.log = {}
self.changed = true
end
function _M:display()
-- If nothing changed, return the same surface as before
if not self.changed then return self.surface end
self.changed = false
-- Erase and the display the map
self.surface:erase()
local i = 1
while i < self.h do
if not self.log[i] then break end
self.surface:drawString(self.font, self.log[i], 0, (i-1) * 16, self.color[1], self.color[2], self.color[3])
i = i + 1
end
return self.surface
end
......@@ -24,10 +24,6 @@ function _M:init(w, h)
self.changed = true
end
function _M:setCurrent()
core.display.set_current_map(self)
end
function _M:call(x, y, pos, entity)
if entity then
table.insert(self.map[x + y * self.w], pos, entity)
......
......@@ -5,11 +5,20 @@ module(..., package.seeall, class.inherit(engine.Actor))
function _M:init(game, t)
self.game = game
t.block_move = _M.bumped
engine.Actor.init(self, t)
end
function _M:move(x, y)
engine.Actor.move(self, self.game.level.map, x, y)
self.game.level.map.fov(self.x, self.y, 20)
self.game.level.map.seens(self.x, self.y, true)
function _M:move(x, y, force)
local moved = false
if force or self.energy.value >= self.game.energy_to_act then
moved = engine.Actor.move(self, self.game.level.map, x, y)
if not force then self.energy.value = self.energy.value - self.game.energy_to_act end
end
return moved
end
function _M:bumped(x, y, e)
self.game.log("%s bumped into %s!", tostring(e.name), tostring(self.name))
return true
end
require "engine.class"
require "engine.Game"
require "engine.GameTurnBased"
require "engine.KeyCommand"
require "engine.LogDisplay"
local Map = require "engine.Map"
local Level = require "engine.Level"
local Entity = require "engine.Entity"
local Actor = require "tome.class.Actor"
local Player = require "tome.class.Player"
local NPC = require "tome.class.NPC"
module(..., package.seeall, class.inherit(engine.Game))
module(..., package.seeall, class.inherit(engine.GameTurnBased))
function _M:init()
engine.Game.init(self, engine.KeyCommand.new())
engine.GameTurnBased.init(self, engine.KeyCommand.new(), 1000, 100)
self:setupCommands()
local map = Map.new(40, 40)
self.log = engine.LogDisplay.new(400, 150)
self.log("Welcome to Tales of Middle Earth!")
local map = Map.new(40, 20)
local floor = Entity.new{display='#', color_r=100, color_g=100, color_b=100}
local e1 = Entity.new{display='#', color_r=255, block_sight=true}
local e2 = Entity.new{display='#', color_g=255, block_sight=true}
local e3 = Entity.new{display='#', color_b=255, block_sight=true, block_move=true}
local e4 = e3:clone{color_r=255}
for i = 0, 39 do for j = 0, 39 do
for i = 0, 39 do for j = 0, 19 do
map(i, j, 1, floor)
end end
......@@ -34,28 +39,96 @@ function _M:init()
map(10, 8, Map.TERRAIN, e3)
local level = Level.new(map)
level:activate()
self:setLevel(level)
self.player = Actor.new(self, {name="player!", display='.', color_r=125, color_g=125, color_b=0})
self.player:move(2, 3)
self.player = Player.new(self, {name="player!", display='.', color_r=125, color_g=125, color_b=0})
self.player:move(4, 3, true)
level:addEntity(self.player)
local m = NPC.new(self, {name="monster!", display='#', color_r=125, color_g=125, color_b=255})
m.energy.mod = 0.38
m:move(1, 3, true)
level:addEntity(m)
-- Ok everything is good to go, activate the game in the engine!
self:setCurrent()
end
function _M:tick()
engine.GameTurnBased.tick(self)
end
function _M:display()
if self.level and self.level.map then
local s = self.level.map:display()
if s then s:toScreen(0, 0) end
end
self.log:display():toScreen(0, 16 * 20 + 5)
end
function _M:setupCommands()
self.key:addCommand("_LEFT", function()
self.player:move(self.player.x - 1, self.player.y)
end)
self.key:addCommand("_RIGHT", function()
self.player:move(self.player.x + 1, self.player.y)
end)
self.key:addCommand("_UP", function()
self.player:move(self.player.x, self.player.y - 1)
end)
self.key:addCommand("_DOWN", function()
self.player:move(self.player.x, self.player.y + 1)
end)
self.key:addCommands
{
_LEFT = function()
if self.player:move(self.player.x - 1, self.player.y) then
self.paused = false
end
end,
_RIGHT = function()
if self.player:move(self.player.x + 1, self.player.y) then
self.paused = false
end
end,
_UP = function()
if self.player:move(self.player.x, self.player.y - 1) then
self.paused = false
end
end,
_DOWN = function()
if self.player:move(self.player.x, self.player.y + 1) then
self.paused = false
end
end,
_KP1 = function()
if self.player:move(self.player.x - 1, self.player.y + 1) then
self.paused = false
end
end,
_KP2 = function()
if self.player:move(self.player.x, self.player.y + 1) then
self.paused = false
end
end,
_KP3 = function()
if self.player:move(self.player.x + 1, self.player.y + 1) then
self.paused = false
end
end,
_KP4 = function()
if self.player:move(self.player.x - 1, self.player.y) then
self.paused = false
end
end,
_KP6 = function()
if self.player:move(self.player.x + 1, self.player.y) then
self.paused = false
end
end,
_KP7 = function()
if self.player:move(self.player.x - 1, self.player.y - 1) then
self.paused = false
end
end,
_KP8 = function()
if self.player:move(self.player.x, self.player.y - 1) then
self.paused = false
end
end,
_KP9 = function()
if self.player:move(self.player.x + 1, self.player.y - 1) then
self.paused = false
end
end,
}
self.key:setCurrent()
end
require "engine.class"
require "tome.class.Actor"
module(..., package.seeall, class.inherit(tome.class.Actor))
function _M:init(game, t)
tome.class.Actor.init(self, game, t)
end
function _M:act()
self:move(self.x + 1, self.y)
end
require "engine.class"
require "tome.class.Actor"
module(..., package.seeall, class.inherit(tome.class.Actor))
function _M:init(game, t)
tome.class.Actor.init(self, game, t)
end
function _M:move(x, y, force)
local moved = tome.class.Actor.move(self, x, y, force)
if self.x and self.y then
self.game.level.map.fov(self.x, self.y, 20)
self.game.level.map.seens(self.x, self.y, true)
end
return moved
end
function _M:act()
self.game.paused = true
end
......@@ -7,6 +7,7 @@
#include "script.h"
#include "display.h"
#include "sge.h"
#include <SDL_ttf.h>
/******************************************************************
******************************************************************
......@@ -136,22 +137,22 @@ static const struct luaL_reg keylib[] =
* Game *
******************************************************************
******************************************************************/
extern int current_gametick;
static int lua_set_current_gametick(lua_State *L)
extern int current_game;
static int lua_set_current_game(lua_State *L)
{
if (current_gametick != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, current_gametick);
if (current_game != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, current_game);
if (lua_isnil(L, 1))
current_gametick = LUA_NOREF;
current_game = LUA_NOREF;
else
current_gametick = luaL_ref(L, LUA_REGISTRYINDEX);
current_game = luaL_ref(L, LUA_REGISTRYINDEX);
return 0;
}
static const struct luaL_reg gamelib[] =
{
{"set_current_gametick", lua_set_current_gametick},
{"set_current_game", lua_set_current_game},
{NULL, NULL},
};
......@@ -160,6 +161,50 @@ static const struct luaL_reg gamelib[] =
* Display *
******************************************************************
******************************************************************/
static int sdl_new_font(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
int size = luaL_checknumber(L, 2);
TTF_Font **f = (TTF_Font**)lua_newuserdata(L, sizeof(TTF_Font*));
auxiliar_setclass(L, "sdl{font}", -1);
*f = TTF_OpenFontRW(PHYSFSRWOPS_openRead(name), TRUE, size);
return 1;
}
static int sdl_free_font(lua_State *L)
{
TTF_Font **f = (TTF_Font**)auxiliar_checkclass(L, "sdl{font}", 1);
TTF_CloseFont(*f);
lua_pushnumber(L, 1);
return 1;
}
static int sdl_surface_drawstring(lua_State *L)
{
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1);
TTF_Font **f = (TTF_Font**)auxiliar_checkclass(L, "sdl{font}", 2);
const char *str = luaL_checkstring(L, 3);
int x = luaL_checknumber(L, 4);
int y = luaL_checknumber(L, 5);
int r = luaL_checknumber(L, 6);
int g = luaL_checknumber(L, 7);
int b = luaL_checknumber(L, 8);
SDL_Color color = {r,g,b};
SDL_Surface *txt = TTF_RenderUTF8_Solid(*f, str, color);
if (txt)
{
sgeDrawImage(*s, txt, x, y);
SDL_FreeSurface(txt);
}
return 0;
}
static int sdl_new_surface(lua_State *L)
{
int w = luaL_checknumber(L, 1);
......@@ -190,20 +235,6 @@ static int sdl_free_surface(lua_State *L)
return 1;
}
extern int current_map;
static int lua_set_current_map(lua_State *L)
{
if (current_map != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, current_map);
if (lua_isnil(L, 1))
current_map = LUA_NOREF;
else
current_map = luaL_ref(L, LUA_REGISTRYINDEX);
return 0;
}
static int lua_display_char(lua_State *L)
{
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1);
......@@ -226,9 +257,21 @@ static int sdl_surface_erase(lua_State *L)
return 0;
}
static int sdl_surface_toscreen(lua_State *L)
{
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1);
int x = luaL_checknumber(L, 2);
int y = luaL_checknumber(L, 3);
if (s && *s)
{
sgeDrawImage(screen, *s, x, y);
}
return 0;
}
static const struct luaL_reg displaylib[] =
{
{"set_current_map", lua_set_current_map},
{"newFont", sdl_new_font},
{"newSurface", sdl_new_surface},
{NULL, NULL},
};
......@@ -238,15 +281,24 @@ static const struct luaL_reg sdl_surface_reg[] =
{"__gc", sdl_free_surface},
{"close", sdl_free_surface},
{"erase", sdl_surface_erase},
{"toScreen", sdl_surface_toscreen},
{"putChar", lua_display_char},
{"drawString", sdl_surface_drawstring},
{NULL, NULL},
};
static const struct luaL_reg sdl_font_reg[] =
{
{"__gc", sdl_free_font},
{"close", sdl_free_font},
{NULL, NULL},
};
int luaopen_core(lua_State *L)
{
auxiliar_newclass(L, "fov{core}", fov_reg);
auxiliar_newclass(L, "sdl{surface}", sdl_surface_reg);
auxiliar_newclass(L, "sdl{font}", sdl_font_reg);
luaL_openlib(L, "core.fov", fovlib, 0);
luaL_openlib(L, "core.display", displaylib, 0);
luaL_openlib(L, "core.key", keylib, 0);
......
......@@ -15,9 +15,8 @@
#include "core_lua.h"
lua_State *L = NULL;
int current_map = LUA_NOREF;
int current_keyhandler = LUA_NOREF;
int current_gametick = LUA_NOREF;
int current_game = LUA_NOREF;
int px = 1, py = 1;
void display_utime()
......@@ -72,33 +71,27 @@ void on_redraw(SGEGAMESTATE *state)
return;
}
if (current_gametick != LUA_NOREF)
if (current_game != LUA_NOREF)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, current_gametick);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
lua_pushstring(L, "tick");
lua_gettable(L, -2);
lua_remove(L, -2);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_gametick);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
lua_call(L, 1, 0);
}
sgeLock(screen);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0x00, 0x00, 0x00));
if (current_map != LUA_NOREF)
if (current_game != LUA_NOREF)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, current_map);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
lua_pushstring(L, "display");
lua_gettable(L, -2);
lua_remove(L, -2);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_map);
lua_call(L, 1, 1);
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", -1);
if (s && *s)
{
sgeDrawImage(screen, *s, 0, 0);
}
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
lua_call(L, 1, 0);
}
sgeUnlock(screen);
......@@ -142,9 +135,6 @@ int run(int argc, char *argv[])
lua_newtable(L);
lua_setglobal(L, "__uids");
/***************** SDL TTF Init *****************/
TTF_Init();
/***************** SDL/SGE2D Init *****************/
SGEGAMESTATEMANAGER *manager;
SGEGAMESTATE *mainstate;
......@@ -153,9 +143,9 @@ int run(int argc, char *argv[])
// initialize engine and set up resolution and depth
sgeInit(NOAUDIO, NOJOYSTICK);
sgeOpenScreen("T-Engine", 800, 600, 32, NOFULLSCREEN);
// sgeHideMouse();
SDL_EnableUNICODE(TRUE);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
TTF_Init();
// add a new gamestate. you will usually have to add different gamestates
// like 'main menu', 'game loop', 'load screen', etc.
......
/*
* This code provides a glue layer between PhysicsFS and Simple Directmedia
* Layer's (SDL) RWops i/o abstraction.
*
* License: this code is public domain. I make no warranty that it is useful,
* correct, harmless, or environmentally safe.
*
* This particular file may be used however you like, including copying it
* verbatim into a closed-source project, exploiting it commercially, and
* removing any trace of my name from the source (although I hope you won't
* do that). I welcome enhancements and corrections to this file, but I do
* not require you to send me patches if you make changes. This code has
* NO WARRANTY.
*
* Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
* Please see LICENSE.txt in the root of the source tree.
*
* SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/
*
* This file was written by Ryan C. Gordon. (icculus@icculus.org).
*/
#include <stdio.h> /* used for SEEK_SET, SEEK_CUR, SEEK_END ... */
#include "physfsrwops.h"
static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
{
PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
int pos = 0;
if (whence == SEEK_SET)
{
pos = offset;
} /* if */
else if (whence == SEEK_CUR)
{
PHYSFS_sint64 current = PHYSFS_tell(handle);
if (current == -1)
{
SDL_SetError("Can't find position in file: %s",
PHYSFS_getLastError());
return(-1);
} /* if */
pos = (int) current;
if ( ((PHYSFS_sint64) pos) != current )
{
SDL_SetError("Can't fit current file position in an int!");
return(-1);
} /* if */
if (offset == 0) /* this is a "tell" call. We're done. */
return(pos);
pos += offset;
} /* else if */
else if (whence == SEEK_END)
{
PHYSFS_sint64 len = PHYSFS_fileLength(handle);
if (len == -1)
{
SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError());
return(-1);
} /* if */
pos = (int) len;
if ( ((PHYSFS_sint64) pos) != len )
{
SDL_SetError("Can't fit end-of-file position in an int!");
return(-1);
} /* if */
pos += offset;
} /* else if */
else
{
SDL_SetError("Invalid 'whence' parameter.");
return(-1);
} /* else */
if ( pos < 0 )
{
SDL_SetError("Attempt to seek past start of file.");
return(-1);
} /* if */
if (!PHYSFS_seek(handle, (PHYSFS_uint64) pos))
{
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return(-1);
} /* if */
return(pos);
} /* physfsrwops_seek */
static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum)
{
PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum);
if (rc != maxnum)
{
if (!PHYSFS_eof(handle)) /* not EOF? Must be an error. */
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
} /* if */
return((int) rc);
} /* physfsrwops_read */
static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num)
{
PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num);
if (rc != num)
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return((int) rc);
} /* physfsrwops_write */
static int physfsrwops_close(SDL_RWops *rw)
{
PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
if (!PHYSFS_close(handle))
{
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return(-1);
} /* if */
SDL_FreeRW(rw);
return(0);
} /* physfsrwops_close */
static SDL_RWops *create_rwops(PHYSFS_File *handle)
{
SDL_RWops *retval = NULL;
if (handle == NULL)
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
else
{
retval = SDL_AllocRW();
if (retval != NULL)
{
retval->seek = physfsrwops_seek;
retval->read = physfsrwops_read;
retval->write = physfsrwops_write;
retval->close = physfsrwops_close;
retval->hidden.unknown.data1 = handle;
} /* if */
} /* else */
return(retval);
} /* create_rwops */
SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_File *handle)
{
SDL_RWops *retval = NULL;
if (handle == NULL)
SDL_SetError("NULL pointer passed to PHYSFSRWOPS_makeRWops().");
else
retval = create_rwops(handle);
return(retval);
} /* PHYSFSRWOPS_makeRWops */
SDL_RWops *PHYSFSRWOPS_openRead(const char *fname)
{
return(create_rwops(PHYSFS_openRead(fname)));
} /* PHYSFSRWOPS_openRead */
SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname)
{
return(create_rwops(PHYSFS_openWrite(fname)));
} /* PHYSFSRWOPS_openWrite */
SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname)
{
return(create_rwops(PHYSFS_openAppend(fname)));
} /* PHYSFSRWOPS_openAppend */
/* end of physfsrwops.c ... */
/*
* This code provides a glue layer between PhysicsFS and Simple Directmedia
* Layer's (SDL) RWops i/o abstraction.
*
* License: this code is public domain. I make no warranty that it is useful,
* correct, harmless, or environmentally safe.
*
* This particular file may be used however you like, including copying it
* verbatim into a closed-source project, exploiting it commercially, and
* removing any trace of my name from the source (although I hope you won't
* do that). I welcome enhancements and corrections to this file, but I do
* not require you to send me patches if you make changes. This code has
* NO WARRANTY.
*
* Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
* Please see LICENSE.txt in the root of the source tree.
*
* SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/
*
* This file was written by Ryan C. Gordon. (icculus@icculus.org).
*/
#ifndef _INCLUDE_PHYSFSRWOPS_H_
#define _INCLUDE_PHYSFSRWOPS_H_
#include "physfs.h"
#include "SDL.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Open a platform-independent filename for reading, and make it accessible
* via an SDL_RWops structure. The file will be closed in PhysicsFS when the
* RWops is closed. PhysicsFS should be configured to your liking before
* opening files through this method.
*
* @param filename File to open in platform-independent notation.
* @return A valid SDL_RWops structure on success, NULL on error. Specifics
* of the error can be gleaned from PHYSFS_getLastError().
*/
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openRead(const char *fname);
/**
* Open a platform-independent filename for writing, and make it accessible
* via an SDL_RWops structure. The file will be closed in PhysicsFS when the
* RWops is closed. PhysicsFS should be configured to your liking before
* opening files through this method.
*
* @param filename File to open in platform-independent notation.
* @return A valid SDL_RWops structure on success, NULL on error. Specifics
* of the error can be gleaned from PHYSFS_getLastError().
*/
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname);
/**
* Open a platform-independent filename for appending, and make it accessible
* via an SDL_RWops structure. The file will be closed in PhysicsFS when the
* RWops is closed. PhysicsFS should be configured to your liking before
* opening files through this method.
*
* @param filename File to open in platform-independent notation.
* @return A valid SDL_RWops structure on success, NULL on error. Specifics
* of the error can be gleaned from PHYSFS_getLastError().
*/
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname);
/**
* Make a SDL_RWops from an existing PhysicsFS file handle. You should
* dispose of any references to the handle after successful creation of
* the RWops. The actual PhysicsFS handle will be destroyed when the
* RWops is closed.
*
* @param handle a valid PhysicsFS file handle.
* @return A valid SDL_RWops structure on success, NULL on error. Specifics
* of the error can be gleaned from PHYSFS_getLastError().
*/
__EXPORT__ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_File *handle);
#ifdef __cplusplus
}
#endif
#endif /* include-once blocker */
/* end of physfsrwops.h ... */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment