diff --git a/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp b/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp index f1cca7b2b..744cea58b 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp @@ -1,7 +1,7 @@ /** \file driver_direct3d_pixel_program.cpp * Direct 3d driver implementation * - * $Id: driver_direct3d_pixel_program.cpp,v 1.1.2.4 2007/07/09 15:26:35 legallo Exp $ + * $Id$ * * \todo manage better the init/release system (if a throw occurs in the init, we must release correctly the driver) */ diff --git a/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp b/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp index 29ec4caf8..cd6c3adf4 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp @@ -1,7 +1,7 @@ /** \file driver_opengl_pixel_program.cpp * OpenGL driver implementation for pixel program manipulation. * - * $Id: driver_opengl_pixel_program.cpp,v 1.1.2.4 2007/07/09 15:29:00 legallo Exp $ + * $Id$ * * \todo manage better the init/release system (if a throw occurs in the init, we must release correctly the driver) */ diff --git a/nel/src/gui/lua_loadlib.c b/nel/src/gui/lua_loadlib.c index 837ec1a2b..8acab487e 100644 --- a/nel/src/gui/lua_loadlib.c +++ b/nel/src/gui/lua_loadlib.c @@ -1,552 +1,552 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdpch.h" -#include -#include -#include "lua_loadlib.h" - -typedef lua_State * (*Tlua_open) (void); -typedef void (*Tlua_close) (lua_State *L); -typedef lua_State *(*Tlua_newthread) (lua_State *L); -typedef lua_CFunction (*Tlua_atpanic) (lua_State *L, lua_CFunction panicf); -typedef int (*Tlua_gettop) (lua_State *L); -typedef void (*Tlua_settop) (lua_State *L, int idx); -typedef void (*Tlua_pushvalue) (lua_State *L, int idx); -typedef void (*Tlua_remove) (lua_State *L, int idx); -typedef void (*Tlua_insert )(lua_State *L, int idx); -typedef void (*Tlua_replace) (lua_State *L, int idx); -typedef int (*Tlua_checkstack) (lua_State *L, int sz); -typedef void (*Tlua_xmove) (lua_State *from, lua_State *to, int n); -typedef int (*Tlua_isnumber) (lua_State *L, int idx); -typedef int (*Tlua_isstring) (lua_State *L, int idx); -typedef int (*Tlua_iscfunction) (lua_State *L, int idx); -typedef int (*Tlua_isuserdata) (lua_State *L, int idx); -typedef int (*Tlua_type) (lua_State *L, int idx); -typedef const char *(*Tlua_typename) (lua_State *L, int tp); -typedef int (*Tlua_equal) (lua_State *L, int idx1, int idx2); -typedef int (*Tlua_rawequal) (lua_State *L, int idx1, int idx2); -typedef int (*Tlua_lessthan) (lua_State *L, int idx1, int idx2); -typedef lua_Number (*Tlua_tonumber) (lua_State *L, int idx); -typedef int (*Tlua_toboolean) (lua_State *L, int idx); -typedef const char *(*Tlua_tostring) (lua_State *L, int idx); -typedef size_t (*Tlua_strlen) (lua_State *L, int idx); -typedef lua_CFunction (*Tlua_tocfunction) (lua_State *L, int idx); -typedef void *(*Tlua_touserdata) (lua_State *L, int idx); -typedef lua_State *(*Tlua_tothread) (lua_State *L, int idx); -typedef const void *(*Tlua_topointer) (lua_State *L, int idx); -typedef void (*Tlua_pushnil) (lua_State *L); -typedef void (*Tlua_pushnumber) (lua_State *L, lua_Number n); -typedef void (*Tlua_pushlstring) (lua_State *L, const char *s, size_t l); -typedef void (*Tlua_pushstring) (lua_State *L, const char *s); -typedef const char *(*Tlua_pushvfstring) (lua_State *L, const char *fmt, va_list argp); -typedef const char *(*Tlua_pushfstring) (lua_State *L, const char *fmt, ...); -typedef void (*Tlua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); -typedef void (*Tlua_pushboolean) (lua_State *L, int b); -typedef void (*Tlua_pushlightuserdata) (lua_State *L, void *p); -typedef void (*Tlua_gettable) (lua_State *L, int idx); -typedef void (*Tlua_rawget) (lua_State *L, int idx); -typedef void (*Tlua_rawgeti) (lua_State *L, int idx, int n); -typedef void (*Tlua_newtable) (lua_State *L); -typedef void *(*Tlua_newuserdata) (lua_State *L, size_t sz); -typedef int (*Tlua_getmetatable) (lua_State *L, int objindex); -typedef void (*Tlua_getfenv) (lua_State *L, int idx); -typedef void (*Tlua_settable) (lua_State *L, int idx); -typedef void (*Tlua_rawset) (lua_State *L, int idx); -typedef void (*Tlua_rawseti) (lua_State *L, int idx, int n); -typedef int (*Tlua_setmetatable) (lua_State *L, int objindex); -typedef int (*Tlua_setfenv) (lua_State *L, int idx); -typedef void (*Tlua_call) (lua_State *L, int nargs, int nresults); -typedef int (*Tlua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); -typedef int (*Tlua_cpcall) (lua_State *L, lua_CFunction func, void *ud); -typedef int (*Tlua_load) (lua_State *L, lua_Chunkreader reader, void *dt, - const char *chunkname); -typedef int (*Tlua_dump) (lua_State *L, lua_Chunkwriter writer, void *data); -typedef int (*Tlua_yield) (lua_State *L, int nresults); -typedef int (*Tlua_resume) (lua_State *L, int narg); -typedef int (*Tlua_getgcthreshold) (lua_State *L); -typedef int (*Tlua_getgccount) (lua_State *L); -typedef void (*Tlua_setgcthreshold) (lua_State *L, int newthreshold); -typedef const char *(*Tlua_version) (void); -typedef int (*Tlua_error) (lua_State *L); -typedef int (*Tlua_next) (lua_State *L, int idx); -typedef void (*Tlua_concat) (lua_State *L, int n); -typedef int (*Tlua_pushupvalues) (lua_State *L); -typedef void (*Tlua_Hook) (lua_State *L, lua_Debug *ar); -typedef int (*Tlua_getstack) (lua_State *L, int level, lua_Debug *ar); -typedef int (*Tlua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); -typedef const char *(*Tlua_getlocal) (lua_State *L, const lua_Debug *ar, int n); -typedef const char *(*Tlua_setlocal) (lua_State *L, const lua_Debug *ar, int n); -typedef const char *(*Tlua_getupvalue) (lua_State *L, int funcindex, int n); -typedef const char *(*Tlua_setupvalue) (lua_State *L, int funcindex, int n); -typedef int (*Tlua_sethook) (lua_State *L, lua_Hook func, int mask, int count); -typedef lua_Hook (*Tlua_gethook) (lua_State *L); -typedef int (*Tlua_gethookmask) (lua_State *L); -typedef int (*Tlua_gethookcount) (lua_State *L); - -// from lauxlib.h -typedef void (*TluaL_openlib) (lua_State *L, const char *libname, - const luaL_reg *l, int nup); -typedef int (*TluaL_getmetafield) (lua_State *L, int obj, const char *e); -typedef int (*TluaL_callmeta) (lua_State *L, int obj, const char *e); -typedef int (*TluaL_typerror) (lua_State *L, int narg, const char *tname); -typedef int (*TluaL_argerror) (lua_State *L, int numarg, const char *extramsg); -typedef const char *(*TluaL_checklstring) (lua_State *L, int numArg, size_t *l); -typedef const char *(*TluaL_optlstring) (lua_State *L, int numArg, - const char *def, size_t *l); -typedef lua_Number (*TluaL_checknumber) (lua_State *L, int numArg); -typedef lua_Number (*TluaL_optnumber) (lua_State *L, int nArg, lua_Number def); - -typedef void (*TluaL_checkstack) (lua_State *L, int sz, const char *msg); -typedef void (*TluaL_checktype) (lua_State *L, int narg, int t); -typedef void (*TluaL_checkany) (lua_State *L, int narg); - -typedef int (*TluaL_newmetatable) (lua_State *L, const char *tname); -typedef void (*TluaL_getmetatable) (lua_State *L, const char *tname); -typedef void *(*TluaL_checkudata) (lua_State *L, int ud, const char *tname); - -typedef void (*TluaL_where) (lua_State *L, int lvl); -typedef int (*TluaL_error) (lua_State *L, const char *fmt, ...); - -typedef int (*TluaL_findstring) (const char *st, const char *const lst[]); - -typedef int (*TluaL_ref) (lua_State *L, int t); -typedef void (*TluaL_unref) (lua_State *L, int t, int ref); - -typedef int (*TluaL_getn) (lua_State *L, int t); -typedef void (*TluaL_setn) (lua_State *L, int t, int n); - -typedef int (*TluaL_loadfile) (lua_State *L, const char *filename); -typedef int (*TluaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, - const char *name); - -typedef void (*TluaL_buffinit) (lua_State *L, luaL_Buffer *B); -typedef char *(*TluaL_prepbuffer) (luaL_Buffer *B); -typedef void (*TluaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); -typedef void (*TluaL_addstring) (luaL_Buffer *B, const char *s); -typedef void (*TluaL_addvalue) (luaL_Buffer *B); -typedef void (*TluaL_pushresult) (luaL_Buffer *B); -typedef int (*Tlua_dofile) (lua_State *L, const char *filename); -typedef int (*Tlua_dostring) (lua_State *L, const char *str); -typedef int (*Tlua_dobuffer) (lua_State *L, const char *buff, size_t sz, - const char *n); - -// from lualib.h -typedef int (*Tluaopen_base) (lua_State *L); -typedef int (*Tluaopen_table) (lua_State *L); -typedef int (*Tluaopen_io) (lua_State *L); -typedef int (*Tluaopen_string) (lua_State *L); -typedef int (*Tluaopen_math) (lua_State *L); -typedef int (*Tluaopen_debug) (lua_State *L); -typedef int (*Tluaopen_loadlib) (lua_State *L); - -// from lua.h -Tlua_open dlllua_open; -Tlua_close dlllua_close; -Tlua_newthread dlllua_newthread; -Tlua_atpanic dlllua_atpanic; -Tlua_gettop dlllua_gettop; -Tlua_settop dlllua_settop; -Tlua_pushvalue dlllua_pushvalue; -Tlua_remove dlllua_remove; -Tlua_insert dlllua_insert ; -Tlua_replace dlllua_replace; -Tlua_checkstack dlllua_checkstack; -Tlua_xmove dlllua_xmove; -Tlua_isnumber dlllua_isnumber; -Tlua_isstring dlllua_isstring; -Tlua_iscfunction dlllua_iscfunction; -Tlua_isuserdata dlllua_isuserdata; -Tlua_type dlllua_type; -Tlua_typename dlllua_typename; -Tlua_equal dlllua_equal; -Tlua_rawequal dlllua_rawequal; -Tlua_lessthan dlllua_lessthan; -Tlua_tonumber dlllua_tonumber; -Tlua_toboolean dlllua_toboolean; -Tlua_tostring dlllua_tostring; -Tlua_strlen dlllua_strlen; -Tlua_tocfunction dlllua_tocfunction; -Tlua_touserdata dlllua_touserdata; -Tlua_tothread dlllua_tothread; -Tlua_topointer dlllua_topointer; -Tlua_pushnil dlllua_pushnil; -Tlua_pushnumber dlllua_pushnumber; -Tlua_pushlstring dlllua_pushlstring; -Tlua_pushstring dlllua_pushstring; -Tlua_pushvfstring dlllua_pushvfstring; -Tlua_pushfstring dlllua_pushfstring; -Tlua_pushcclosure dlllua_pushcclosure; -Tlua_pushboolean dlllua_pushboolean; -Tlua_pushlightuserdata dlllua_pushlightuserdata; -Tlua_gettable dlllua_gettable; -Tlua_rawget dlllua_rawget; -Tlua_rawgeti dlllua_rawgeti; -Tlua_newtable dlllua_newtable; -Tlua_newuserdata dlllua_newuserdata; -Tlua_getmetatable dlllua_getmetatable; -Tlua_getfenv dlllua_getfenv; -Tlua_settable dlllua_settable; -Tlua_rawset dlllua_rawset; -Tlua_rawseti dlllua_rawseti; -Tlua_setmetatable dlllua_setmetatable; -Tlua_setfenv dlllua_setfenv; -Tlua_call dlllua_call; -Tlua_pcall dlllua_pcall; -Tlua_cpcall dlllua_cpcall; -Tlua_load dlllua_load; -Tlua_dump dlllua_dump; -Tlua_yield dlllua_yield; -Tlua_resume dlllua_resume; -Tlua_getgcthreshold dlllua_getgcthreshold; -Tlua_getgccount dlllua_getgccount; -Tlua_setgcthreshold dlllua_setgcthreshold; -Tlua_version dlllua_version; -Tlua_error dlllua_error; -Tlua_next dlllua_next; -Tlua_concat dlllua_concat; -Tlua_pushupvalues dlllua_pushupvalues; -Tlua_getstack dlllua_getstack; -Tlua_getinfo dlllua_getinfo; -Tlua_getlocal dlllua_getlocal; -Tlua_setlocal dlllua_setlocal; -Tlua_getupvalue dlllua_getupvalue; -Tlua_setupvalue dlllua_setupvalue; -Tlua_sethook dlllua_sethook; -Tlua_gethook dlllua_gethook; -Tlua_gethookmask dlllua_gethookmask; -Tlua_gethookcount dlllua_gethookcount; -// from lauxlib.h -TluaL_openlib dllluaL_openlib; -TluaL_getmetafield dllluaL_getmetafield; -TluaL_callmeta dllluaL_callmeta; -TluaL_typerror dllluaL_typerror; -TluaL_argerror dllluaL_argerror; -TluaL_checklstring dllluaL_checklstring; -TluaL_optlstring dllluaL_optlstring; -TluaL_checknumber dllluaL_checknumber; -TluaL_optnumber dllluaL_optnumber; -TluaL_checkstack dllluaL_checkstack; -TluaL_checktype dllluaL_checktype; -TluaL_checkany dllluaL_checkany; -TluaL_newmetatable dllluaL_newmetatable; -TluaL_getmetatable dllluaL_getmetatable; -TluaL_checkudata dllluaL_checkudata; -TluaL_where dllluaL_where; -TluaL_error dllluaL_error; -TluaL_findstring dllluaL_findstring; -TluaL_ref dllluaL_ref; -TluaL_unref dllluaL_unref; -TluaL_getn dllluaL_getn; -TluaL_setn dllluaL_setn; -TluaL_loadfile dllluaL_loadfile; -TluaL_loadbuffer dllluaL_loadbuffer; -TluaL_buffinit dllluaL_buffinit; -TluaL_prepbuffer dllluaL_prepbuffer; -TluaL_addlstring dllluaL_addlstring; -TluaL_addstring dllluaL_addstring; -TluaL_addvalue dllluaL_addvalue; -TluaL_pushresult dllluaL_pushresult; -Tlua_dofile dlllua_dofile; -Tlua_dostring dlllua_dostring; -Tlua_dobuffer dlllua_dobuffer; -// from lua lib.h -Tluaopen_base dllluaopen_base; -Tluaopen_table dllluaopen_table; -Tluaopen_io dllluaopen_io; -Tluaopen_string dllluaopen_string; -Tluaopen_math dllluaopen_math; -Tluaopen_debug dllluaopen_debug; -Tluaopen_loadlib dllluaopen_loadlib; - -// call to actual dll function -lua_State *lua_open (void) { return dlllua_open(); } -void lua_close (lua_State *L) { dlllua_close(L); } -lua_State *lua_newthread (lua_State *L) { return dlllua_newthread(L); } -lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { return dlllua_atpanic(L, panicf); } -int lua_gettop (lua_State *L) { return dlllua_gettop(L); } -void lua_settop (lua_State *L, int idx) { dlllua_settop(L, idx); } -void lua_pushvalue (lua_State *L, int idx) { dlllua_pushvalue(L, idx); } -void lua_remove (lua_State *L, int idx) { dlllua_remove(L, idx); } -void lua_insert (lua_State *L, int idx) { dlllua_insert (L, idx); } -void lua_replace (lua_State *L, int idx) { dlllua_replace(L, idx); } -int lua_checkstack (lua_State *L, int sz) { return dlllua_checkstack(L, sz); } -void lua_xmove (lua_State *from, lua_State *to, int n) { dlllua_xmove(from, to, n); } -int lua_isnumber (lua_State *L, int idx) { return dlllua_isnumber(L, idx); } -int lua_isstring (lua_State *L, int idx) { return dlllua_isstring(L, idx); } -int lua_iscfunction (lua_State *L, int idx) { return dlllua_iscfunction(L, idx); } -int lua_isuserdata (lua_State *L, int idx) { return dlllua_isuserdata(L, idx); } -int lua_type (lua_State *L, int idx) { return dlllua_type(L, idx); } -const char *lua_typename (lua_State *L, int tp) { return dlllua_typename(L, tp); } -int lua_equal (lua_State *L, int idx1, int idx2) { return dlllua_equal(L, idx1, idx2); } -int lua_rawequal (lua_State *L, int idx1, int idx2) { return dlllua_rawequal(L, idx1, idx2); } -int lua_lessthan (lua_State *L, int idx1, int idx2) { return dlllua_lessthan(L, idx1, idx2); } -lua_Number lua_tonumber (lua_State *L, int idx) { return dlllua_tonumber(L, idx); } -int lua_toboolean (lua_State *L, int idx) { return dlllua_toboolean(L, idx); } -const char *lua_tostring (lua_State *L, int idx) { return dlllua_tostring(L, idx); } -size_t lua_strlen (lua_State *L, int idx) { return dlllua_strlen(L, idx); } -lua_CFunction lua_tocfunction (lua_State *L, int idx) { return dlllua_tocfunction(L, idx); } -void *lua_touserdata (lua_State *L, int idx) { return dlllua_touserdata(L, idx); } -lua_State *lua_tothread (lua_State *L, int idx) { return dlllua_tothread(L, idx); } -const void *lua_topointer (lua_State *L, int idx) { return dlllua_topointer(L, idx); } -void lua_pushnil (lua_State *L) { dlllua_pushnil(L); } -void lua_pushnumber (lua_State *L, lua_Number n) { dlllua_pushnumber(L, n); } -void lua_pushlstring (lua_State *L, const char *s, size_t l) { dlllua_pushlstring(L, s, l); } -void lua_pushstring (lua_State *L, const char *s) { dlllua_pushstring(L, s); } - -const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp) -{ - const char *result; - va_list _args; - va_start (_args, fmt); - result = dlllua_pushvfstring(L, fmt, _args); - va_end(_args); - return result; -} - -const char *lua_pushfstring (lua_State *L, const char *fmt, ...) -{ - const char *result; - va_list _args; - va_start (_args, fmt); - result = dlllua_pushfstring(L, fmt, _args); - va_end(_args); - return result; -} - -void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { dlllua_pushcclosure(L, fn, n); } -void lua_pushboolean (lua_State *L, int b) { dlllua_pushboolean(L, b); } -void lua_pushlightuserdata (lua_State *L, void *p) { dlllua_pushlightuserdata(L, p); } -void lua_gettable (lua_State *L, int idx) { dlllua_gettable(L, idx); } -void lua_rawget (lua_State *L, int idx) { dlllua_rawget(L, idx); } -void lua_rawgeti (lua_State *L, int idx, int n) { dlllua_rawgeti(L, idx, n); } -void lua_newtable (lua_State *L) { dlllua_newtable(L); } -void *lua_newuserdata (lua_State *L, size_t sz) { return dlllua_newuserdata(L, sz); } -int lua_getmetatable (lua_State *L, int objindex) { return dlllua_getmetatable(L, objindex); } -void lua_getfenv (lua_State *L, int idx) { dlllua_getfenv(L, idx); } -void lua_settable (lua_State *L, int idx) { dlllua_settable(L, idx); } -void lua_rawset (lua_State *L, int idx) { dlllua_rawset(L, idx); } -void lua_rawseti (lua_State *L, int idx, int n) { dlllua_rawseti(L, idx, n); } -int lua_setmetatable (lua_State *L, int objindex) { return dlllua_setmetatable(L, objindex); } -int lua_setfenv (lua_State *L, int idx) { return dlllua_setfenv(L, idx); } -void lua_call (lua_State *L, int nargs, int nresults) { dlllua_call(L, nargs, nresults); } -int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { return dlllua_pcall(L, nargs, nresults, errfunc); } -int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { return dlllua_cpcall(L, func, ud); } -int lua_load (lua_State *L, lua_Chunkreader reader, void *dt, const char *chunkname) -{ - return dlllua_load(L, reader, dt, chunkname); -} -int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { return dlllua_dump(L, writer, data); } -int lua_yield (lua_State *L, int nresults) { return dlllua_yield(L, nresults); } -int lua_resume (lua_State *L, int narg) { return dlllua_resume(L, narg); } -int lua_getgcthreshold (lua_State *L) { return dlllua_getgcthreshold(L); } -int lua_getgccount (lua_State *L) { return dlllua_getgccount(L); } -void lua_setgcthreshold (lua_State *L, int newthreshold) { dlllua_setgcthreshold(L, newthreshold); } -const char *lua_version (void) { return dlllua_version(); } -int lua_error (lua_State *L) { return dlllua_error(L); } -int lua_next (lua_State *L, int idx) { return dlllua_next(L, idx); } -void lua_concat (lua_State *L, int n) { dlllua_concat(L, n); } -int lua_pushupvalues (lua_State *L) { return dlllua_pushupvalues(L); } -int lua_getstack (lua_State *L, int level, lua_Debug *ar) { return dlllua_getstack(L, level, ar); } -int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { return dlllua_getinfo(L, what, ar); } -const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { return dlllua_getlocal(L, ar, n); } -const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { return dlllua_setlocal(L, ar, n); } -const char *lua_getupvalue (lua_State *L, int funcindex, int n) { return dlllua_getupvalue(L, funcindex, n); } -const char *lua_setupvalue (lua_State *L, int funcindex, int n) { return dlllua_setupvalue(L, funcindex, n); } -int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { return dlllua_sethook(L, func, mask, count); } -lua_Hook lua_gethook (lua_State *L) { return dlllua_gethook(L); } -int lua_gethookmask (lua_State *L) { return dlllua_gethookmask(L); } -int lua_gethookcount (lua_State *L) { return dlllua_gethookcount(L); } - -// from lauxlib.h -void luaL_openlib (lua_State *L, const char *libname, const luaL_reg *l, int nup) { dllluaL_openlib(L, libname, l, nup); } -int luaL_getmetafield (lua_State *L, int obj, const char *e) { return dllluaL_getmetafield(L, obj, e); } -int luaL_callmeta (lua_State *L, int obj, const char *e) { return dllluaL_callmeta(L, obj, e); } -int luaL_typerror (lua_State *L, int narg, const char *tname) { return dllluaL_typerror(L, narg, tname); } -int luaL_argerror (lua_State *L, int numarg, const char *extramsg) { return dllluaL_argerror(L, numarg, extramsg); } -const char *luaL_checklstring (lua_State *L, int numArg, size_t *l) { return dllluaL_checklstring(L, numArg, l); } -const char *luaL_optlstring (lua_State *L, int numArg, const char *def, size_t *l) { return dllluaL_optlstring(L, numArg, def, l); } -lua_Number luaL_checknumber (lua_State *L, int numArg) { return dllluaL_checknumber(L, numArg); } -lua_Number luaL_optnumber (lua_State *L, int nArg, lua_Number def) { return dllluaL_optnumber(L, nArg, def); } -void luaL_checkstack (lua_State *L, int sz, const char *msg) { dllluaL_checkstack(L, sz, msg); } -void luaL_checktype (lua_State *L, int narg, int t) { dllluaL_checktype(L, narg, t); } -void luaL_checkany (lua_State *L, int narg) { dllluaL_checkany(L, narg); } -int luaL_newmetatable (lua_State *L, const char *tname) { return dllluaL_newmetatable(L, tname); } -void luaL_getmetatable (lua_State *L, const char *tname) { dllluaL_getmetatable(L, tname); } -void *luaL_checkudata (lua_State *L, int ud, const char *tname) { return dllluaL_checkudata(L, ud, tname); } -void luaL_where (lua_State *L, int lvl) { dllluaL_where(L, lvl); } - -int luaL_error (lua_State *L, const char *fmt, ...) -{ - int result; - va_list _args; - va_start (_args, fmt); - result = dllluaL_error(L, fmt, _args); - va_end(_args); - return result; -} -int luaL_findstring (const char *st, const char *const lst[]) { return dllluaL_findstring(st, lst); } -int luaL_ref (lua_State *L, int t) { return dllluaL_ref(L, t); } -void luaL_unref (lua_State *L, int t, int ref) { dllluaL_unref(L, t, ref); } -int luaL_getn (lua_State *L, int t) { return dllluaL_getn(L, t); } -void luaL_setn (lua_State *L, int t, int n) { dllluaL_setn(L, t, n); } -int luaL_loadfile (lua_State *L, const char *filename) { return dllluaL_loadfile(L, filename); } -int luaL_loadbuffer (lua_State *L, const char *buff, size_t sz, const char *name) { return dllluaL_loadbuffer(L, buff, sz, name); } - -void luaL_buffinit (lua_State *L, luaL_Buffer *B) { dllluaL_buffinit(L, B); } -char *luaL_prepbuffer (luaL_Buffer *B) { return dllluaL_prepbuffer(B); } - -void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { dllluaL_addlstring(B, s, l); } -void luaL_addstring (luaL_Buffer *B, const char *s) { dllluaL_addstring(B, s); } -void luaL_addvalue (luaL_Buffer *B) { dllluaL_addvalue(B); } -void luaL_pushresult (luaL_Buffer *B) { dllluaL_pushresult(B); } -int lua_dofile (lua_State *L, const char *filename) { return dlllua_dofile(L, filename); } -int lua_dostring (lua_State *L, const char *str) { return dlllua_dostring(L, str); } -int lua_dobuffer (lua_State *L, const char *buff, size_t sz, const char *n) { return dlllua_dobuffer(L, buff, sz, n); } - -// from lualib.h -int luaopen_base (lua_State *L) { return dllluaopen_base(L); } -int luaopen_table (lua_State *L) { return dllluaopen_table(L); } -int luaopen_io (lua_State *L) { return dllluaopen_io(L); } -int luaopen_string (lua_State *L) { return dllluaopen_string(L); } -int luaopen_math (lua_State *L) { return dllluaopen_math(L); } -int luaopen_debug (lua_State *L) { return dllluaopen_debug(L); } -int luaopen_loadlib (lua_State *L) { return dllluaopen_loadlib(L); } - - -int loadLuaDLL() -{ - HMODULE libHandle = LoadLibrary("lua.dll"); - if (!libHandle) return 0; -#define GET_LUA_PROC(name) dll##name = (T##name) GetProcAddress(libHandle, #name); if (!dll##name) return 0; - // from lua.h - GET_LUA_PROC(lua_close) - GET_LUA_PROC(lua_newthread) - GET_LUA_PROC(lua_atpanic) - GET_LUA_PROC(lua_gettop) - GET_LUA_PROC(lua_settop) - GET_LUA_PROC(lua_pushvalue) - GET_LUA_PROC(lua_remove) - GET_LUA_PROC(lua_insert) - GET_LUA_PROC(lua_replace) - GET_LUA_PROC(lua_checkstack) - GET_LUA_PROC(lua_xmove) - GET_LUA_PROC(lua_isnumber) - GET_LUA_PROC(lua_isstring) - GET_LUA_PROC(lua_iscfunction) - GET_LUA_PROC(lua_isuserdata) - GET_LUA_PROC(lua_type) - GET_LUA_PROC(lua_typename) - GET_LUA_PROC(lua_equal) - GET_LUA_PROC(lua_rawequal) - GET_LUA_PROC(lua_lessthan) - GET_LUA_PROC(lua_tonumber) - GET_LUA_PROC(lua_toboolean) - GET_LUA_PROC(lua_tostring) - GET_LUA_PROC(lua_strlen) - GET_LUA_PROC(lua_tocfunction) - GET_LUA_PROC(lua_touserdata) - GET_LUA_PROC(lua_tothread) - GET_LUA_PROC(lua_topointer) - GET_LUA_PROC(lua_pushnil) - GET_LUA_PROC(lua_pushnumber) - GET_LUA_PROC(lua_pushlstring) - GET_LUA_PROC(lua_pushstring) - GET_LUA_PROC(lua_pushcclosure) - GET_LUA_PROC(lua_pushboolean) - GET_LUA_PROC(lua_pushlightuserdata) - GET_LUA_PROC(lua_gettable) - GET_LUA_PROC(lua_rawget) - GET_LUA_PROC(lua_rawgeti) - GET_LUA_PROC(lua_newtable) - GET_LUA_PROC(lua_newuserdata) - GET_LUA_PROC(lua_getmetatable) - GET_LUA_PROC(lua_getfenv) - GET_LUA_PROC(lua_settable) - GET_LUA_PROC(lua_rawset) - GET_LUA_PROC(lua_rawseti) - GET_LUA_PROC(lua_setmetatable) - GET_LUA_PROC(lua_setfenv) - GET_LUA_PROC(lua_call) - GET_LUA_PROC(lua_pcall) - GET_LUA_PROC(lua_cpcall) - GET_LUA_PROC(lua_load) - GET_LUA_PROC(lua_dump) - GET_LUA_PROC(lua_yield) - GET_LUA_PROC(lua_resume) - GET_LUA_PROC(lua_getgcthreshold) - GET_LUA_PROC(lua_getgccount) - GET_LUA_PROC(lua_setgcthreshold) - GET_LUA_PROC(lua_version) - GET_LUA_PROC(lua_error) - GET_LUA_PROC(lua_next) - GET_LUA_PROC(lua_concat) - GET_LUA_PROC(lua_pushupvalues) - GET_LUA_PROC(lua_getstack) - GET_LUA_PROC(lua_getinfo) - GET_LUA_PROC(lua_getlocal) - GET_LUA_PROC(lua_setlocal) - GET_LUA_PROC(lua_getupvalue) - GET_LUA_PROC(lua_setupvalue) - GET_LUA_PROC(lua_sethook) - GET_LUA_PROC(lua_gethook) - GET_LUA_PROC(lua_gethookmask) - GET_LUA_PROC(lua_gethookcount) - // from lauxlib.h - GET_LUA_PROC(luaL_openlib) - GET_LUA_PROC(luaL_getmetafield) - GET_LUA_PROC(luaL_callmeta) - GET_LUA_PROC(luaL_typerror) - GET_LUA_PROC(luaL_argerror) - GET_LUA_PROC(luaL_checklstring) - GET_LUA_PROC(luaL_optlstring) - GET_LUA_PROC(luaL_checknumber) - GET_LUA_PROC(luaL_optnumber) - GET_LUA_PROC(luaL_checkstack) - GET_LUA_PROC(luaL_checktype) - GET_LUA_PROC(luaL_checkany) - GET_LUA_PROC(luaL_newmetatable) - GET_LUA_PROC(luaL_getmetatable) - GET_LUA_PROC(luaL_checkudata) - GET_LUA_PROC(luaL_where) - GET_LUA_PROC(luaL_error) - GET_LUA_PROC(luaL_findstring) - GET_LUA_PROC(luaL_ref) - GET_LUA_PROC(luaL_unref) - GET_LUA_PROC(luaL_getn) - GET_LUA_PROC(luaL_setn) - GET_LUA_PROC(luaL_loadfile) - GET_LUA_PROC(luaL_loadbuffer) - GET_LUA_PROC(luaL_buffinit) - GET_LUA_PROC(luaL_prepbuffer) - GET_LUA_PROC(luaL_addlstring) - GET_LUA_PROC(luaL_addstring) - GET_LUA_PROC(luaL_addvalue) - GET_LUA_PROC(luaL_pushresult) - GET_LUA_PROC(lua_dofile) - GET_LUA_PROC(lua_dostring) - GET_LUA_PROC(lua_dobuffer) - // from lua lib.h - GET_LUA_PROC(luaopen_base) - GET_LUA_PROC(luaopen_table) - GET_LUA_PROC(luaopen_io) - GET_LUA_PROC(luaopen_string) - GET_LUA_PROC(luaopen_math) - GET_LUA_PROC(luaopen_debug) - GET_LUA_PROC(luaopen_loadlib) - - return 1; -} +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include +#include +#include "lua_loadlib.h" + +typedef lua_State * (*Tlua_open) (void); +typedef void (*Tlua_close) (lua_State *L); +typedef lua_State *(*Tlua_newthread) (lua_State *L); +typedef lua_CFunction (*Tlua_atpanic) (lua_State *L, lua_CFunction panicf); +typedef int (*Tlua_gettop) (lua_State *L); +typedef void (*Tlua_settop) (lua_State *L, int idx); +typedef void (*Tlua_pushvalue) (lua_State *L, int idx); +typedef void (*Tlua_remove) (lua_State *L, int idx); +typedef void (*Tlua_insert )(lua_State *L, int idx); +typedef void (*Tlua_replace) (lua_State *L, int idx); +typedef int (*Tlua_checkstack) (lua_State *L, int sz); +typedef void (*Tlua_xmove) (lua_State *from, lua_State *to, int n); +typedef int (*Tlua_isnumber) (lua_State *L, int idx); +typedef int (*Tlua_isstring) (lua_State *L, int idx); +typedef int (*Tlua_iscfunction) (lua_State *L, int idx); +typedef int (*Tlua_isuserdata) (lua_State *L, int idx); +typedef int (*Tlua_type) (lua_State *L, int idx); +typedef const char *(*Tlua_typename) (lua_State *L, int tp); +typedef int (*Tlua_equal) (lua_State *L, int idx1, int idx2); +typedef int (*Tlua_rawequal) (lua_State *L, int idx1, int idx2); +typedef int (*Tlua_lessthan) (lua_State *L, int idx1, int idx2); +typedef lua_Number (*Tlua_tonumber) (lua_State *L, int idx); +typedef int (*Tlua_toboolean) (lua_State *L, int idx); +typedef const char *(*Tlua_tostring) (lua_State *L, int idx); +typedef size_t (*Tlua_strlen) (lua_State *L, int idx); +typedef lua_CFunction (*Tlua_tocfunction) (lua_State *L, int idx); +typedef void *(*Tlua_touserdata) (lua_State *L, int idx); +typedef lua_State *(*Tlua_tothread) (lua_State *L, int idx); +typedef const void *(*Tlua_topointer) (lua_State *L, int idx); +typedef void (*Tlua_pushnil) (lua_State *L); +typedef void (*Tlua_pushnumber) (lua_State *L, lua_Number n); +typedef void (*Tlua_pushlstring) (lua_State *L, const char *s, size_t l); +typedef void (*Tlua_pushstring) (lua_State *L, const char *s); +typedef const char *(*Tlua_pushvfstring) (lua_State *L, const char *fmt, va_list argp); +typedef const char *(*Tlua_pushfstring) (lua_State *L, const char *fmt, ...); +typedef void (*Tlua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +typedef void (*Tlua_pushboolean) (lua_State *L, int b); +typedef void (*Tlua_pushlightuserdata) (lua_State *L, void *p); +typedef void (*Tlua_gettable) (lua_State *L, int idx); +typedef void (*Tlua_rawget) (lua_State *L, int idx); +typedef void (*Tlua_rawgeti) (lua_State *L, int idx, int n); +typedef void (*Tlua_newtable) (lua_State *L); +typedef void *(*Tlua_newuserdata) (lua_State *L, size_t sz); +typedef int (*Tlua_getmetatable) (lua_State *L, int objindex); +typedef void (*Tlua_getfenv) (lua_State *L, int idx); +typedef void (*Tlua_settable) (lua_State *L, int idx); +typedef void (*Tlua_rawset) (lua_State *L, int idx); +typedef void (*Tlua_rawseti) (lua_State *L, int idx, int n); +typedef int (*Tlua_setmetatable) (lua_State *L, int objindex); +typedef int (*Tlua_setfenv) (lua_State *L, int idx); +typedef void (*Tlua_call) (lua_State *L, int nargs, int nresults); +typedef int (*Tlua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +typedef int (*Tlua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +typedef int (*Tlua_load) (lua_State *L, lua_Chunkreader reader, void *dt, + const char *chunkname); +typedef int (*Tlua_dump) (lua_State *L, lua_Chunkwriter writer, void *data); +typedef int (*Tlua_yield) (lua_State *L, int nresults); +typedef int (*Tlua_resume) (lua_State *L, int narg); +typedef int (*Tlua_getgcthreshold) (lua_State *L); +typedef int (*Tlua_getgccount) (lua_State *L); +typedef void (*Tlua_setgcthreshold) (lua_State *L, int newthreshold); +typedef const char *(*Tlua_version) (void); +typedef int (*Tlua_error) (lua_State *L); +typedef int (*Tlua_next) (lua_State *L, int idx); +typedef void (*Tlua_concat) (lua_State *L, int n); +typedef int (*Tlua_pushupvalues) (lua_State *L); +typedef void (*Tlua_Hook) (lua_State *L, lua_Debug *ar); +typedef int (*Tlua_getstack) (lua_State *L, int level, lua_Debug *ar); +typedef int (*Tlua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +typedef const char *(*Tlua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +typedef const char *(*Tlua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +typedef const char *(*Tlua_getupvalue) (lua_State *L, int funcindex, int n); +typedef const char *(*Tlua_setupvalue) (lua_State *L, int funcindex, int n); +typedef int (*Tlua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +typedef lua_Hook (*Tlua_gethook) (lua_State *L); +typedef int (*Tlua_gethookmask) (lua_State *L); +typedef int (*Tlua_gethookcount) (lua_State *L); + +// from lauxlib.h +typedef void (*TluaL_openlib) (lua_State *L, const char *libname, + const luaL_reg *l, int nup); +typedef int (*TluaL_getmetafield) (lua_State *L, int obj, const char *e); +typedef int (*TluaL_callmeta) (lua_State *L, int obj, const char *e); +typedef int (*TluaL_typerror) (lua_State *L, int narg, const char *tname); +typedef int (*TluaL_argerror) (lua_State *L, int numarg, const char *extramsg); +typedef const char *(*TluaL_checklstring) (lua_State *L, int numArg, size_t *l); +typedef const char *(*TluaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +typedef lua_Number (*TluaL_checknumber) (lua_State *L, int numArg); +typedef lua_Number (*TluaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +typedef void (*TluaL_checkstack) (lua_State *L, int sz, const char *msg); +typedef void (*TluaL_checktype) (lua_State *L, int narg, int t); +typedef void (*TluaL_checkany) (lua_State *L, int narg); + +typedef int (*TluaL_newmetatable) (lua_State *L, const char *tname); +typedef void (*TluaL_getmetatable) (lua_State *L, const char *tname); +typedef void *(*TluaL_checkudata) (lua_State *L, int ud, const char *tname); + +typedef void (*TluaL_where) (lua_State *L, int lvl); +typedef int (*TluaL_error) (lua_State *L, const char *fmt, ...); + +typedef int (*TluaL_findstring) (const char *st, const char *const lst[]); + +typedef int (*TluaL_ref) (lua_State *L, int t); +typedef void (*TluaL_unref) (lua_State *L, int t, int ref); + +typedef int (*TluaL_getn) (lua_State *L, int t); +typedef void (*TluaL_setn) (lua_State *L, int t, int n); + +typedef int (*TluaL_loadfile) (lua_State *L, const char *filename); +typedef int (*TluaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); + +typedef void (*TluaL_buffinit) (lua_State *L, luaL_Buffer *B); +typedef char *(*TluaL_prepbuffer) (luaL_Buffer *B); +typedef void (*TluaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +typedef void (*TluaL_addstring) (luaL_Buffer *B, const char *s); +typedef void (*TluaL_addvalue) (luaL_Buffer *B); +typedef void (*TluaL_pushresult) (luaL_Buffer *B); +typedef int (*Tlua_dofile) (lua_State *L, const char *filename); +typedef int (*Tlua_dostring) (lua_State *L, const char *str); +typedef int (*Tlua_dobuffer) (lua_State *L, const char *buff, size_t sz, + const char *n); + +// from lualib.h +typedef int (*Tluaopen_base) (lua_State *L); +typedef int (*Tluaopen_table) (lua_State *L); +typedef int (*Tluaopen_io) (lua_State *L); +typedef int (*Tluaopen_string) (lua_State *L); +typedef int (*Tluaopen_math) (lua_State *L); +typedef int (*Tluaopen_debug) (lua_State *L); +typedef int (*Tluaopen_loadlib) (lua_State *L); + +// from lua.h +Tlua_open dlllua_open; +Tlua_close dlllua_close; +Tlua_newthread dlllua_newthread; +Tlua_atpanic dlllua_atpanic; +Tlua_gettop dlllua_gettop; +Tlua_settop dlllua_settop; +Tlua_pushvalue dlllua_pushvalue; +Tlua_remove dlllua_remove; +Tlua_insert dlllua_insert ; +Tlua_replace dlllua_replace; +Tlua_checkstack dlllua_checkstack; +Tlua_xmove dlllua_xmove; +Tlua_isnumber dlllua_isnumber; +Tlua_isstring dlllua_isstring; +Tlua_iscfunction dlllua_iscfunction; +Tlua_isuserdata dlllua_isuserdata; +Tlua_type dlllua_type; +Tlua_typename dlllua_typename; +Tlua_equal dlllua_equal; +Tlua_rawequal dlllua_rawequal; +Tlua_lessthan dlllua_lessthan; +Tlua_tonumber dlllua_tonumber; +Tlua_toboolean dlllua_toboolean; +Tlua_tostring dlllua_tostring; +Tlua_strlen dlllua_strlen; +Tlua_tocfunction dlllua_tocfunction; +Tlua_touserdata dlllua_touserdata; +Tlua_tothread dlllua_tothread; +Tlua_topointer dlllua_topointer; +Tlua_pushnil dlllua_pushnil; +Tlua_pushnumber dlllua_pushnumber; +Tlua_pushlstring dlllua_pushlstring; +Tlua_pushstring dlllua_pushstring; +Tlua_pushvfstring dlllua_pushvfstring; +Tlua_pushfstring dlllua_pushfstring; +Tlua_pushcclosure dlllua_pushcclosure; +Tlua_pushboolean dlllua_pushboolean; +Tlua_pushlightuserdata dlllua_pushlightuserdata; +Tlua_gettable dlllua_gettable; +Tlua_rawget dlllua_rawget; +Tlua_rawgeti dlllua_rawgeti; +Tlua_newtable dlllua_newtable; +Tlua_newuserdata dlllua_newuserdata; +Tlua_getmetatable dlllua_getmetatable; +Tlua_getfenv dlllua_getfenv; +Tlua_settable dlllua_settable; +Tlua_rawset dlllua_rawset; +Tlua_rawseti dlllua_rawseti; +Tlua_setmetatable dlllua_setmetatable; +Tlua_setfenv dlllua_setfenv; +Tlua_call dlllua_call; +Tlua_pcall dlllua_pcall; +Tlua_cpcall dlllua_cpcall; +Tlua_load dlllua_load; +Tlua_dump dlllua_dump; +Tlua_yield dlllua_yield; +Tlua_resume dlllua_resume; +Tlua_getgcthreshold dlllua_getgcthreshold; +Tlua_getgccount dlllua_getgccount; +Tlua_setgcthreshold dlllua_setgcthreshold; +Tlua_version dlllua_version; +Tlua_error dlllua_error; +Tlua_next dlllua_next; +Tlua_concat dlllua_concat; +Tlua_pushupvalues dlllua_pushupvalues; +Tlua_getstack dlllua_getstack; +Tlua_getinfo dlllua_getinfo; +Tlua_getlocal dlllua_getlocal; +Tlua_setlocal dlllua_setlocal; +Tlua_getupvalue dlllua_getupvalue; +Tlua_setupvalue dlllua_setupvalue; +Tlua_sethook dlllua_sethook; +Tlua_gethook dlllua_gethook; +Tlua_gethookmask dlllua_gethookmask; +Tlua_gethookcount dlllua_gethookcount; +// from lauxlib.h +TluaL_openlib dllluaL_openlib; +TluaL_getmetafield dllluaL_getmetafield; +TluaL_callmeta dllluaL_callmeta; +TluaL_typerror dllluaL_typerror; +TluaL_argerror dllluaL_argerror; +TluaL_checklstring dllluaL_checklstring; +TluaL_optlstring dllluaL_optlstring; +TluaL_checknumber dllluaL_checknumber; +TluaL_optnumber dllluaL_optnumber; +TluaL_checkstack dllluaL_checkstack; +TluaL_checktype dllluaL_checktype; +TluaL_checkany dllluaL_checkany; +TluaL_newmetatable dllluaL_newmetatable; +TluaL_getmetatable dllluaL_getmetatable; +TluaL_checkudata dllluaL_checkudata; +TluaL_where dllluaL_where; +TluaL_error dllluaL_error; +TluaL_findstring dllluaL_findstring; +TluaL_ref dllluaL_ref; +TluaL_unref dllluaL_unref; +TluaL_getn dllluaL_getn; +TluaL_setn dllluaL_setn; +TluaL_loadfile dllluaL_loadfile; +TluaL_loadbuffer dllluaL_loadbuffer; +TluaL_buffinit dllluaL_buffinit; +TluaL_prepbuffer dllluaL_prepbuffer; +TluaL_addlstring dllluaL_addlstring; +TluaL_addstring dllluaL_addstring; +TluaL_addvalue dllluaL_addvalue; +TluaL_pushresult dllluaL_pushresult; +Tlua_dofile dlllua_dofile; +Tlua_dostring dlllua_dostring; +Tlua_dobuffer dlllua_dobuffer; +// from lua lib.h +Tluaopen_base dllluaopen_base; +Tluaopen_table dllluaopen_table; +Tluaopen_io dllluaopen_io; +Tluaopen_string dllluaopen_string; +Tluaopen_math dllluaopen_math; +Tluaopen_debug dllluaopen_debug; +Tluaopen_loadlib dllluaopen_loadlib; + +// call to actual dll function +lua_State *lua_open (void) { return dlllua_open(); } +void lua_close (lua_State *L) { dlllua_close(L); } +lua_State *lua_newthread (lua_State *L) { return dlllua_newthread(L); } +lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { return dlllua_atpanic(L, panicf); } +int lua_gettop (lua_State *L) { return dlllua_gettop(L); } +void lua_settop (lua_State *L, int idx) { dlllua_settop(L, idx); } +void lua_pushvalue (lua_State *L, int idx) { dlllua_pushvalue(L, idx); } +void lua_remove (lua_State *L, int idx) { dlllua_remove(L, idx); } +void lua_insert (lua_State *L, int idx) { dlllua_insert (L, idx); } +void lua_replace (lua_State *L, int idx) { dlllua_replace(L, idx); } +int lua_checkstack (lua_State *L, int sz) { return dlllua_checkstack(L, sz); } +void lua_xmove (lua_State *from, lua_State *to, int n) { dlllua_xmove(from, to, n); } +int lua_isnumber (lua_State *L, int idx) { return dlllua_isnumber(L, idx); } +int lua_isstring (lua_State *L, int idx) { return dlllua_isstring(L, idx); } +int lua_iscfunction (lua_State *L, int idx) { return dlllua_iscfunction(L, idx); } +int lua_isuserdata (lua_State *L, int idx) { return dlllua_isuserdata(L, idx); } +int lua_type (lua_State *L, int idx) { return dlllua_type(L, idx); } +const char *lua_typename (lua_State *L, int tp) { return dlllua_typename(L, tp); } +int lua_equal (lua_State *L, int idx1, int idx2) { return dlllua_equal(L, idx1, idx2); } +int lua_rawequal (lua_State *L, int idx1, int idx2) { return dlllua_rawequal(L, idx1, idx2); } +int lua_lessthan (lua_State *L, int idx1, int idx2) { return dlllua_lessthan(L, idx1, idx2); } +lua_Number lua_tonumber (lua_State *L, int idx) { return dlllua_tonumber(L, idx); } +int lua_toboolean (lua_State *L, int idx) { return dlllua_toboolean(L, idx); } +const char *lua_tostring (lua_State *L, int idx) { return dlllua_tostring(L, idx); } +size_t lua_strlen (lua_State *L, int idx) { return dlllua_strlen(L, idx); } +lua_CFunction lua_tocfunction (lua_State *L, int idx) { return dlllua_tocfunction(L, idx); } +void *lua_touserdata (lua_State *L, int idx) { return dlllua_touserdata(L, idx); } +lua_State *lua_tothread (lua_State *L, int idx) { return dlllua_tothread(L, idx); } +const void *lua_topointer (lua_State *L, int idx) { return dlllua_topointer(L, idx); } +void lua_pushnil (lua_State *L) { dlllua_pushnil(L); } +void lua_pushnumber (lua_State *L, lua_Number n) { dlllua_pushnumber(L, n); } +void lua_pushlstring (lua_State *L, const char *s, size_t l) { dlllua_pushlstring(L, s, l); } +void lua_pushstring (lua_State *L, const char *s) { dlllua_pushstring(L, s); } + +const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp) +{ + const char *result; + va_list _args; + va_start (_args, fmt); + result = dlllua_pushvfstring(L, fmt, _args); + va_end(_args); + return result; +} + +const char *lua_pushfstring (lua_State *L, const char *fmt, ...) +{ + const char *result; + va_list _args; + va_start (_args, fmt); + result = dlllua_pushfstring(L, fmt, _args); + va_end(_args); + return result; +} + +void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { dlllua_pushcclosure(L, fn, n); } +void lua_pushboolean (lua_State *L, int b) { dlllua_pushboolean(L, b); } +void lua_pushlightuserdata (lua_State *L, void *p) { dlllua_pushlightuserdata(L, p); } +void lua_gettable (lua_State *L, int idx) { dlllua_gettable(L, idx); } +void lua_rawget (lua_State *L, int idx) { dlllua_rawget(L, idx); } +void lua_rawgeti (lua_State *L, int idx, int n) { dlllua_rawgeti(L, idx, n); } +void lua_newtable (lua_State *L) { dlllua_newtable(L); } +void *lua_newuserdata (lua_State *L, size_t sz) { return dlllua_newuserdata(L, sz); } +int lua_getmetatable (lua_State *L, int objindex) { return dlllua_getmetatable(L, objindex); } +void lua_getfenv (lua_State *L, int idx) { dlllua_getfenv(L, idx); } +void lua_settable (lua_State *L, int idx) { dlllua_settable(L, idx); } +void lua_rawset (lua_State *L, int idx) { dlllua_rawset(L, idx); } +void lua_rawseti (lua_State *L, int idx, int n) { dlllua_rawseti(L, idx, n); } +int lua_setmetatable (lua_State *L, int objindex) { return dlllua_setmetatable(L, objindex); } +int lua_setfenv (lua_State *L, int idx) { return dlllua_setfenv(L, idx); } +void lua_call (lua_State *L, int nargs, int nresults) { dlllua_call(L, nargs, nresults); } +int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { return dlllua_pcall(L, nargs, nresults, errfunc); } +int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { return dlllua_cpcall(L, func, ud); } +int lua_load (lua_State *L, lua_Chunkreader reader, void *dt, const char *chunkname) +{ + return dlllua_load(L, reader, dt, chunkname); +} +int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { return dlllua_dump(L, writer, data); } +int lua_yield (lua_State *L, int nresults) { return dlllua_yield(L, nresults); } +int lua_resume (lua_State *L, int narg) { return dlllua_resume(L, narg); } +int lua_getgcthreshold (lua_State *L) { return dlllua_getgcthreshold(L); } +int lua_getgccount (lua_State *L) { return dlllua_getgccount(L); } +void lua_setgcthreshold (lua_State *L, int newthreshold) { dlllua_setgcthreshold(L, newthreshold); } +const char *lua_version (void) { return dlllua_version(); } +int lua_error (lua_State *L) { return dlllua_error(L); } +int lua_next (lua_State *L, int idx) { return dlllua_next(L, idx); } +void lua_concat (lua_State *L, int n) { dlllua_concat(L, n); } +int lua_pushupvalues (lua_State *L) { return dlllua_pushupvalues(L); } +int lua_getstack (lua_State *L, int level, lua_Debug *ar) { return dlllua_getstack(L, level, ar); } +int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { return dlllua_getinfo(L, what, ar); } +const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { return dlllua_getlocal(L, ar, n); } +const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { return dlllua_setlocal(L, ar, n); } +const char *lua_getupvalue (lua_State *L, int funcindex, int n) { return dlllua_getupvalue(L, funcindex, n); } +const char *lua_setupvalue (lua_State *L, int funcindex, int n) { return dlllua_setupvalue(L, funcindex, n); } +int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { return dlllua_sethook(L, func, mask, count); } +lua_Hook lua_gethook (lua_State *L) { return dlllua_gethook(L); } +int lua_gethookmask (lua_State *L) { return dlllua_gethookmask(L); } +int lua_gethookcount (lua_State *L) { return dlllua_gethookcount(L); } + +// from lauxlib.h +void luaL_openlib (lua_State *L, const char *libname, const luaL_reg *l, int nup) { dllluaL_openlib(L, libname, l, nup); } +int luaL_getmetafield (lua_State *L, int obj, const char *e) { return dllluaL_getmetafield(L, obj, e); } +int luaL_callmeta (lua_State *L, int obj, const char *e) { return dllluaL_callmeta(L, obj, e); } +int luaL_typerror (lua_State *L, int narg, const char *tname) { return dllluaL_typerror(L, narg, tname); } +int luaL_argerror (lua_State *L, int numarg, const char *extramsg) { return dllluaL_argerror(L, numarg, extramsg); } +const char *luaL_checklstring (lua_State *L, int numArg, size_t *l) { return dllluaL_checklstring(L, numArg, l); } +const char *luaL_optlstring (lua_State *L, int numArg, const char *def, size_t *l) { return dllluaL_optlstring(L, numArg, def, l); } +lua_Number luaL_checknumber (lua_State *L, int numArg) { return dllluaL_checknumber(L, numArg); } +lua_Number luaL_optnumber (lua_State *L, int nArg, lua_Number def) { return dllluaL_optnumber(L, nArg, def); } +void luaL_checkstack (lua_State *L, int sz, const char *msg) { dllluaL_checkstack(L, sz, msg); } +void luaL_checktype (lua_State *L, int narg, int t) { dllluaL_checktype(L, narg, t); } +void luaL_checkany (lua_State *L, int narg) { dllluaL_checkany(L, narg); } +int luaL_newmetatable (lua_State *L, const char *tname) { return dllluaL_newmetatable(L, tname); } +void luaL_getmetatable (lua_State *L, const char *tname) { dllluaL_getmetatable(L, tname); } +void *luaL_checkudata (lua_State *L, int ud, const char *tname) { return dllluaL_checkudata(L, ud, tname); } +void luaL_where (lua_State *L, int lvl) { dllluaL_where(L, lvl); } + +int luaL_error (lua_State *L, const char *fmt, ...) +{ + int result; + va_list _args; + va_start (_args, fmt); + result = dllluaL_error(L, fmt, _args); + va_end(_args); + return result; +} +int luaL_findstring (const char *st, const char *const lst[]) { return dllluaL_findstring(st, lst); } +int luaL_ref (lua_State *L, int t) { return dllluaL_ref(L, t); } +void luaL_unref (lua_State *L, int t, int ref) { dllluaL_unref(L, t, ref); } +int luaL_getn (lua_State *L, int t) { return dllluaL_getn(L, t); } +void luaL_setn (lua_State *L, int t, int n) { dllluaL_setn(L, t, n); } +int luaL_loadfile (lua_State *L, const char *filename) { return dllluaL_loadfile(L, filename); } +int luaL_loadbuffer (lua_State *L, const char *buff, size_t sz, const char *name) { return dllluaL_loadbuffer(L, buff, sz, name); } + +void luaL_buffinit (lua_State *L, luaL_Buffer *B) { dllluaL_buffinit(L, B); } +char *luaL_prepbuffer (luaL_Buffer *B) { return dllluaL_prepbuffer(B); } + +void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { dllluaL_addlstring(B, s, l); } +void luaL_addstring (luaL_Buffer *B, const char *s) { dllluaL_addstring(B, s); } +void luaL_addvalue (luaL_Buffer *B) { dllluaL_addvalue(B); } +void luaL_pushresult (luaL_Buffer *B) { dllluaL_pushresult(B); } +int lua_dofile (lua_State *L, const char *filename) { return dlllua_dofile(L, filename); } +int lua_dostring (lua_State *L, const char *str) { return dlllua_dostring(L, str); } +int lua_dobuffer (lua_State *L, const char *buff, size_t sz, const char *n) { return dlllua_dobuffer(L, buff, sz, n); } + +// from lualib.h +int luaopen_base (lua_State *L) { return dllluaopen_base(L); } +int luaopen_table (lua_State *L) { return dllluaopen_table(L); } +int luaopen_io (lua_State *L) { return dllluaopen_io(L); } +int luaopen_string (lua_State *L) { return dllluaopen_string(L); } +int luaopen_math (lua_State *L) { return dllluaopen_math(L); } +int luaopen_debug (lua_State *L) { return dllluaopen_debug(L); } +int luaopen_loadlib (lua_State *L) { return dllluaopen_loadlib(L); } + + +int loadLuaDLL() +{ + HMODULE libHandle = LoadLibrary("lua.dll"); + if (!libHandle) return 0; +#define GET_LUA_PROC(name) dll##name = (T##name) GetProcAddress(libHandle, #name); if (!dll##name) return 0; + // from lua.h + GET_LUA_PROC(lua_close) + GET_LUA_PROC(lua_newthread) + GET_LUA_PROC(lua_atpanic) + GET_LUA_PROC(lua_gettop) + GET_LUA_PROC(lua_settop) + GET_LUA_PROC(lua_pushvalue) + GET_LUA_PROC(lua_remove) + GET_LUA_PROC(lua_insert) + GET_LUA_PROC(lua_replace) + GET_LUA_PROC(lua_checkstack) + GET_LUA_PROC(lua_xmove) + GET_LUA_PROC(lua_isnumber) + GET_LUA_PROC(lua_isstring) + GET_LUA_PROC(lua_iscfunction) + GET_LUA_PROC(lua_isuserdata) + GET_LUA_PROC(lua_type) + GET_LUA_PROC(lua_typename) + GET_LUA_PROC(lua_equal) + GET_LUA_PROC(lua_rawequal) + GET_LUA_PROC(lua_lessthan) + GET_LUA_PROC(lua_tonumber) + GET_LUA_PROC(lua_toboolean) + GET_LUA_PROC(lua_tostring) + GET_LUA_PROC(lua_strlen) + GET_LUA_PROC(lua_tocfunction) + GET_LUA_PROC(lua_touserdata) + GET_LUA_PROC(lua_tothread) + GET_LUA_PROC(lua_topointer) + GET_LUA_PROC(lua_pushnil) + GET_LUA_PROC(lua_pushnumber) + GET_LUA_PROC(lua_pushlstring) + GET_LUA_PROC(lua_pushstring) + GET_LUA_PROC(lua_pushcclosure) + GET_LUA_PROC(lua_pushboolean) + GET_LUA_PROC(lua_pushlightuserdata) + GET_LUA_PROC(lua_gettable) + GET_LUA_PROC(lua_rawget) + GET_LUA_PROC(lua_rawgeti) + GET_LUA_PROC(lua_newtable) + GET_LUA_PROC(lua_newuserdata) + GET_LUA_PROC(lua_getmetatable) + GET_LUA_PROC(lua_getfenv) + GET_LUA_PROC(lua_settable) + GET_LUA_PROC(lua_rawset) + GET_LUA_PROC(lua_rawseti) + GET_LUA_PROC(lua_setmetatable) + GET_LUA_PROC(lua_setfenv) + GET_LUA_PROC(lua_call) + GET_LUA_PROC(lua_pcall) + GET_LUA_PROC(lua_cpcall) + GET_LUA_PROC(lua_load) + GET_LUA_PROC(lua_dump) + GET_LUA_PROC(lua_yield) + GET_LUA_PROC(lua_resume) + GET_LUA_PROC(lua_getgcthreshold) + GET_LUA_PROC(lua_getgccount) + GET_LUA_PROC(lua_setgcthreshold) + GET_LUA_PROC(lua_version) + GET_LUA_PROC(lua_error) + GET_LUA_PROC(lua_next) + GET_LUA_PROC(lua_concat) + GET_LUA_PROC(lua_pushupvalues) + GET_LUA_PROC(lua_getstack) + GET_LUA_PROC(lua_getinfo) + GET_LUA_PROC(lua_getlocal) + GET_LUA_PROC(lua_setlocal) + GET_LUA_PROC(lua_getupvalue) + GET_LUA_PROC(lua_setupvalue) + GET_LUA_PROC(lua_sethook) + GET_LUA_PROC(lua_gethook) + GET_LUA_PROC(lua_gethookmask) + GET_LUA_PROC(lua_gethookcount) + // from lauxlib.h + GET_LUA_PROC(luaL_openlib) + GET_LUA_PROC(luaL_getmetafield) + GET_LUA_PROC(luaL_callmeta) + GET_LUA_PROC(luaL_typerror) + GET_LUA_PROC(luaL_argerror) + GET_LUA_PROC(luaL_checklstring) + GET_LUA_PROC(luaL_optlstring) + GET_LUA_PROC(luaL_checknumber) + GET_LUA_PROC(luaL_optnumber) + GET_LUA_PROC(luaL_checkstack) + GET_LUA_PROC(luaL_checktype) + GET_LUA_PROC(luaL_checkany) + GET_LUA_PROC(luaL_newmetatable) + GET_LUA_PROC(luaL_getmetatable) + GET_LUA_PROC(luaL_checkudata) + GET_LUA_PROC(luaL_where) + GET_LUA_PROC(luaL_error) + GET_LUA_PROC(luaL_findstring) + GET_LUA_PROC(luaL_ref) + GET_LUA_PROC(luaL_unref) + GET_LUA_PROC(luaL_getn) + GET_LUA_PROC(luaL_setn) + GET_LUA_PROC(luaL_loadfile) + GET_LUA_PROC(luaL_loadbuffer) + GET_LUA_PROC(luaL_buffinit) + GET_LUA_PROC(luaL_prepbuffer) + GET_LUA_PROC(luaL_addlstring) + GET_LUA_PROC(luaL_addstring) + GET_LUA_PROC(luaL_addvalue) + GET_LUA_PROC(luaL_pushresult) + GET_LUA_PROC(lua_dofile) + GET_LUA_PROC(lua_dostring) + GET_LUA_PROC(lua_dobuffer) + // from lua lib.h + GET_LUA_PROC(luaopen_base) + GET_LUA_PROC(luaopen_table) + GET_LUA_PROC(luaopen_io) + GET_LUA_PROC(luaopen_string) + GET_LUA_PROC(luaopen_math) + GET_LUA_PROC(luaopen_debug) + GET_LUA_PROC(luaopen_loadlib) + + return 1; +} diff --git a/nel/tools/3d/build_gamedata/processes/anim/sh/build.sh b/nel/tools/3d/build_gamedata/processes/anim/sh/build.sh index f46eb3c56..a20d120df 100644 --- a/nel/tools/3d/build_gamedata/processes/anim/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/anim/sh/build.sh @@ -1,16 +1,16 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Log error -echo ------- > log.log -echo --- Build anim : optimze >> log.log -echo ------- >> log.log -echo ------- -echo --- Build anim : optimze -echo ------- -date >> log.log -date - - -# Execute the build -anim_builder.exe anim_export anim ../../cfg/properties.cfg +#!/bin/bash +rm log.log 2> /dev/null + +# Log error +echo ------- > log.log +echo --- Build anim : optimze >> log.log +echo ------- >> log.log +echo ------- +echo --- Build anim : optimze +echo ------- +date >> log.log +date + + +# Execute the build +anim_builder.exe anim_export anim ../../cfg/properties.cfg diff --git a/nel/tools/3d/build_gamedata/processes/anim/sh/export.sh b/nel/tools/3d/build_gamedata/processes/anim/sh/export.sh index 7bcd4ac35..fe5ded077 100644 --- a/nel/tools/3d/build_gamedata/processes/anim/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/anim/sh/export.sh @@ -1,57 +1,57 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export animation files (.anim) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "anim_export_timeout" | sed -e 's/anim_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the anim directories -anim_source_directories=`cat ../../cfg/directories.cfg | grep "anim_source_directory" | sed -e 's/anim_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export animation >> log.log -echo ------- >> log.log -echo ------- -echo --- Export animation -echo ------- -date >> log.log -date - -# For each directoy - -for i in $anim_source_directories ; do - # Copy the script - cat maxscript/anim_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/anim/log.log&g" | sed -e "s&anim_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/anim/anim_export&g" > $max_directory/scripts/anim_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export animation files (.anim) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "anim_export_timeout" | sed -e 's/anim_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the anim directories +anim_source_directories=`cat ../../cfg/directories.cfg | grep "anim_source_directory" | sed -e 's/anim_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export animation >> log.log +echo ------- >> log.log +echo ------- +echo --- Export animation +echo ------- +date >> log.log +date + +# For each directoy + +for i in $anim_source_directories ; do + # Copy the script + cat maxscript/anim_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/anim/log.log&g" | sed -e "s&anim_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/anim/anim_export&g" > $max_directory/scripts/anim_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript anim_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/anim/sh/install.sh b/nel/tools/3d/build_gamedata/processes/anim/sh/install.sh index a956d24c0..5c4a8dbe7 100644 --- a/nel/tools/3d/build_gamedata/processes/anim/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/anim/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install anim in the client data - -# Get the anim install directory -anim_install_directory=`cat ../../cfg/directories.cfg | grep "anim_install_directory" | sed -e 's/anim_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install animation >> log.log -echo ------- >> log.log -echo ------- -echo --- Install animation -echo ------- -date >> log.log -date - -cp -u -p -R anim/. $client_directory/$anim_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install anim in the client data + +# Get the anim install directory +anim_install_directory=`cat ../../cfg/directories.cfg | grep "anim_install_directory" | sed -e 's/anim_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install animation >> log.log +echo ------- >> log.log +echo ------- +echo --- Install animation +echo ------- +date >> log.log +date + +cp -u -p -R anim/. $client_directory/$anim_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/clodbank/sh/build.sh b/nel/tools/3d/build_gamedata/processes/clodbank/sh/build.sh index f932e5aa7..e77fe82f5 100644 --- a/nel/tools/3d/build_gamedata/processes/clodbank/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/clodbank/sh/build.sh @@ -1,26 +1,26 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Log error -echo ------- > log.log -echo --- Build clod : build .clodbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Build clod : build .clodbank -echo ------- -date >> log.log -date - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the lod config file in the database -clod_config_file=`cat ../../cfg/config.cfg | grep "clod_config_file" | sed -e 's/clod_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the Lod character bank name -clod_bank_file_name=`cat ../../cfg/config.cfg | grep "clod_bank_file_name" | sed -e 's/clod_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - - -# Execute the build -build_clod_bank.exe cfg/local_path.cfg $database_directory/$clod_config_file clodbank/$clod_bank_file_name - +#!/bin/bash +rm log.log 2> /dev/null + +# Log error +echo ------- > log.log +echo --- Build clod : build .clodbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Build clod : build .clodbank +echo ------- +date >> log.log +date + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the lod config file in the database +clod_config_file=`cat ../../cfg/config.cfg | grep "clod_config_file" | sed -e 's/clod_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the Lod character bank name +clod_bank_file_name=`cat ../../cfg/config.cfg | grep "clod_bank_file_name" | sed -e 's/clod_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + + +# Execute the build +build_clod_bank.exe cfg/local_path.cfg $database_directory/$clod_config_file clodbank/$clod_bank_file_name + diff --git a/nel/tools/3d/build_gamedata/processes/clodbank/sh/export.sh b/nel/tools/3d/build_gamedata/processes/clodbank/sh/export.sh index e0480f3d5..007febdf0 100644 --- a/nel/tools/3d/build_gamedata/processes/clodbank/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/clodbank/sh/export.sh @@ -1,60 +1,60 @@ -#!/bin/bash -rm log.log 2> /dev/null - - -# *** Export character lod shape files (.clod) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "shape_export_timeout" | sed -e 's/shape_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the shape directories -clod_source_directories=`cat ../../cfg/directories.cfg | grep "clod_source_directory" | sed -e 's/clod_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export clod >> log.log -echo ------- >> log.log -echo ------- -echo --- Export clod -echo ------- -date >> log.log -date - -# For each directoy - -for i in $clod_source_directories ; do - # Copy the script - cat maxscript/clod_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/clodbank/log.log&g" | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_clod&$build_gamedata_directory/processes/clodbank/clod&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/clodbank/tag&g" > $max_directory/scripts/clod_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - - +#!/bin/bash +rm log.log 2> /dev/null + + +# *** Export character lod shape files (.clod) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "shape_export_timeout" | sed -e 's/shape_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the shape directories +clod_source_directories=`cat ../../cfg/directories.cfg | grep "clod_source_directory" | sed -e 's/clod_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export clod >> log.log +echo ------- >> log.log +echo ------- +echo --- Export clod +echo ------- +date >> log.log +date + +# For each directoy + +for i in $clod_source_directories ; do + # Copy the script + cat maxscript/clod_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/clodbank/log.log&g" | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_clod&$build_gamedata_directory/processes/clodbank/clod&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/clodbank/tag&g" > $max_directory/scripts/clod_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + + diff --git a/nel/tools/3d/build_gamedata/processes/clodbank/sh/install.sh b/nel/tools/3d/build_gamedata/processes/clodbank/sh/install.sh index 3eb96ca6b..406af468d 100644 --- a/nel/tools/3d/build_gamedata/processes/clodbank/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/clodbank/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install clodbank in the client data, in the "shapes/" directory - -# Get the shape install directory -shape_install_directory=`cat ../../cfg/directories.cfg | grep "shape_install_directory" | sed -e 's/shape_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install clodbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Install clodbank -echo ------- -date >> log.log -date - -cp -u -p -R clodbank/. $client_directory/$shape_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install clodbank in the client data, in the "shapes/" directory + +# Get the shape install directory +shape_install_directory=`cat ../../cfg/directories.cfg | grep "shape_install_directory" | sed -e 's/shape_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install clodbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Install clodbank +echo ------- +date >> log.log +date + +cp -u -p -R clodbank/. $client_directory/$shape_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/displace/sh/export.sh b/nel/tools/3d/build_gamedata/processes/displace/sh/export.sh index 648e5c9b5..3b109ed29 100644 --- a/nel/tools/3d/build_gamedata/processes/displace/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/displace/sh/export.sh @@ -1,29 +1,29 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export displace tile (.tga) - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the displace directories -displace_source_directories=`cat ../../cfg/directories.cfg | grep "displace_source_directories" | sed -e 's/displace_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export displace >> log.log -echo ------- >> log.log -echo ------- -echo --- Export displace -echo ------- -date >> log.log -date - -# For each displace directory -for i in $displace_source_directories ; do - # Copy - cp -u -p $database_directory/$i/*.[tT][gG][aA] tga 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export displace tile (.tga) + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the displace directories +displace_source_directories=`cat ../../cfg/directories.cfg | grep "displace_source_directories" | sed -e 's/displace_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export displace >> log.log +echo ------- >> log.log +echo ------- +echo --- Export displace +echo ------- +date >> log.log +date + +# For each displace directory +for i in $displace_source_directories ; do + # Copy + cp -u -p $database_directory/$i/*.[tT][gG][aA] tga 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/displace/sh/install.sh b/nel/tools/3d/build_gamedata/processes/displace/sh/install.sh index 9babbe05b..8455e0216 100644 --- a/nel/tools/3d/build_gamedata/processes/displace/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/displace/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the displace in the client data - -# Get the displace install directory -displace_install_directory=`cat ../../cfg/directories.cfg | grep "displace_install_directory" | sed -e 's/displace_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install displace >> log.log -echo ------- >> log.log -echo ------- -echo --- Install displace -echo ------- -date >> log.log -date - -cp -u -p -R tga/. $client_directory/$displace_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the displace in the client data + +# Get the displace install directory +displace_install_directory=`cat ../../cfg/directories.cfg | grep "displace_install_directory" | sed -e 's/displace_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install displace >> log.log +echo ------- >> log.log +echo ------- +echo --- Install displace +echo ------- +date >> log.log +date + +cp -u -p -R tga/. $client_directory/$displace_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/farbank/sh/build.sh b/nel/tools/3d/build_gamedata/processes/farbank/sh/build.sh index 58af3f4ed..c8dd64d02 100644 --- a/nel/tools/3d/build_gamedata/processes/farbank/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/farbank/sh/build.sh @@ -1,89 +1,89 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build the farbank - -build_farbank='build_far_bank.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "farbank_build_timeout" | sed -e 's/farbank_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the tiles root directories -tile_root_source_directory=`cat ../../cfg/directories.cfg | grep "tile_root_source_directory" | sed -e 's/tile_root_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the extension list -multiple_tiles_postfix=`cat ../../cfg/config.cfg | grep "multiple_tiles_postfix" | sed -e 's/multiple_tiles_postfix//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Build farbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Build farbank -echo ------- -date >> log.log -date - -# list all the bank -bank_list=`ls -1 ../smallbank/smallbank/*.[sS][mM][aA][lL][lL][bB][aA][nN][kK]` - -# For each bank -for i in $bank_list ; do - - if ( test "$multiple_tiles_postfix" ) then - - for j in $multiple_tiles_postfix ; do - - # Destination the name - dest=`echo $i | sed -e "s&\.smallbank&\$j.farbank&g" | sed -e 's&../smallbank/smallbank&farbank&g'` - echo $i - echo $dest - - # Make the dependencies - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - $exec_timeout $timeout $build_farbank $i $dest -d$database_directory/$tile_root_source_directory$j/ -p$j - if ( test -e $dest ) - then - echo OK $dest >> log.log - else - echo ERROR building $dest >> log.log - fi - else - echo SKIPPED $dest >> log.log - fi - - # Idle - ../../idle.bat - - done - - else - - # Destination the name - dest=`echo $i | sed -e 's&\.smallbank&\.farbank&g' | sed -e 's&../smallbank/smallbank&farbank&g'` - echo $i - echo $dest - - # Make the dependencies - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - $exec_timeout $timeout $build_farbank $i $dest - if ( test -e $dest ) - then - echo OK $dest >> log.log - else - echo ERROR building $dest >> log.log - fi - else - echo SKIPPED $dest >> log.log - fi - fi - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# Build the farbank + +build_farbank='build_far_bank.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "farbank_build_timeout" | sed -e 's/farbank_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the tiles root directories +tile_root_source_directory=`cat ../../cfg/directories.cfg | grep "tile_root_source_directory" | sed -e 's/tile_root_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the extension list +multiple_tiles_postfix=`cat ../../cfg/config.cfg | grep "multiple_tiles_postfix" | sed -e 's/multiple_tiles_postfix//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Build farbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Build farbank +echo ------- +date >> log.log +date + +# list all the bank +bank_list=`ls -1 ../smallbank/smallbank/*.[sS][mM][aA][lL][lL][bB][aA][nN][kK]` + +# For each bank +for i in $bank_list ; do + + if ( test "$multiple_tiles_postfix" ) then + + for j in $multiple_tiles_postfix ; do + + # Destination the name + dest=`echo $i | sed -e "s&\.smallbank&\$j.farbank&g" | sed -e 's&../smallbank/smallbank&farbank&g'` + echo $i + echo $dest + + # Make the dependencies + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + $exec_timeout $timeout $build_farbank $i $dest -d$database_directory/$tile_root_source_directory$j/ -p$j + if ( test -e $dest ) + then + echo OK $dest >> log.log + else + echo ERROR building $dest >> log.log + fi + else + echo SKIPPED $dest >> log.log + fi + + # Idle + ../../idle.bat + + done + + else + + # Destination the name + dest=`echo $i | sed -e 's&\.smallbank&\.farbank&g' | sed -e 's&../smallbank/smallbank&farbank&g'` + echo $i + echo $dest + + # Make the dependencies + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + $exec_timeout $timeout $build_farbank $i $dest + if ( test -e $dest ) + then + echo OK $dest >> log.log + else + echo ERROR building $dest >> log.log + fi + else + echo SKIPPED $dest >> log.log + fi + fi + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/farbank/sh/install.sh b/nel/tools/3d/build_gamedata/processes/farbank/sh/install.sh index 0504193b7..6d748800e 100644 --- a/nel/tools/3d/build_gamedata/processes/farbank/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/farbank/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the farbank in the client data - -# Get the bank install directory -bank_install_directory=`cat ../../cfg/directories.cfg | grep "bank_install_directory" | sed -e 's/bank_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install farbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Install farbank -echo ------- -date >> log.log -date - -cp -u -p -R farbank/. $client_directory/$bank_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the farbank in the client data + +# Get the bank install directory +bank_install_directory=`cat ../../cfg/directories.cfg | grep "bank_install_directory" | sed -e 's/bank_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install farbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Install farbank +echo ------- +date >> log.log +date + +cp -u -p -R farbank/. $client_directory/$bank_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/font/sh/export.sh b/nel/tools/3d/build_gamedata/processes/font/sh/export.sh index 8bbbcfeac..0a16e017e 100644 --- a/nel/tools/3d/build_gamedata/processes/font/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/font/sh/export.sh @@ -1,32 +1,32 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export fonts - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the ps directories -font_source_directories=`cat ../../cfg/directories.cfg | grep "font_source_directories" | sed -e 's/font_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export fonts >> log.log -echo ------- >> log.log -echo ------- -echo --- Export fonts -echo ------- -date >> log.log -date - -# For each font directory -for i in $font_source_directories ; do - # Copy - cp -u -p $database_directory/$i/*.[tT][tT][fF] fonts 2>> log.log - cp -u -p $database_directory/$i/*.[aA][fF][mM] fonts 2>> log.log - cp -u -p $database_directory/$i/*.[pP][fF][bB] fonts 2>> log.log - cp -u -p $database_directory/$i/*.[pP][fF][mM] fonts 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export fonts + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the ps directories +font_source_directories=`cat ../../cfg/directories.cfg | grep "font_source_directories" | sed -e 's/font_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export fonts >> log.log +echo ------- >> log.log +echo ------- +echo --- Export fonts +echo ------- +date >> log.log +date + +# For each font directory +for i in $font_source_directories ; do + # Copy + cp -u -p $database_directory/$i/*.[tT][tT][fF] fonts 2>> log.log + cp -u -p $database_directory/$i/*.[aA][fF][mM] fonts 2>> log.log + cp -u -p $database_directory/$i/*.[pP][fF][bB] fonts 2>> log.log + cp -u -p $database_directory/$i/*.[pP][fF][mM] fonts 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/font/sh/install.sh b/nel/tools/3d/build_gamedata/processes/font/sh/install.sh index b4eeb34a3..b2f36bd1b 100644 --- a/nel/tools/3d/build_gamedata/processes/font/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/font/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the fonts in the client data - -# Get the fonts install directory -fonts_install_directory=`cat ../../cfg/directories.cfg | grep "fonts_install_directory" | sed -e 's/fonts_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install fonts >> log.log -echo ------- >> log.log -echo ------- -echo --- Install fonts -echo ------- -date >> log.log -date - -cp -u -p -R fonts/. $client_directory/$fonts_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the fonts in the client data + +# Get the fonts install directory +fonts_install_directory=`cat ../../cfg/directories.cfg | grep "fonts_install_directory" | sed -e 's/fonts_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install fonts >> log.log +echo ------- >> log.log +echo ------- +echo --- Install fonts +echo ------- +date >> log.log +date + +cp -u -p -R fonts/. $client_directory/$fonts_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/ig/sh/build.sh b/nel/tools/3d/build_gamedata/processes/ig/sh/build.sh index d2e618b8c..73f946f40 100644 --- a/nel/tools/3d/build_gamedata/processes/ig/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/ig/sh/build.sh @@ -1,304 +1,304 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# ig_land_max: landscape IG eported from 3dsmax not elevated by the heightmap -# ig_land_max_elev: landscape IG eported from 3dsmax elevated by the heightmap -# ig_land_ligo: landscape IG found in ligo bricks not elevated by the heightmap -# ig_land_ligo_elev: landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -# ig_land_ld: landscape IG generated by the land exporter (already elevated by the land exporter) - -# ig_land: final IG directory for landscape IGs -# ig_land_compare: Tmp final IG directory for landscape IGs before comparison -# ig_other: final IG directory for village or construction IGs - -# Log error -echo ------- >> log.log -echo --- Build ig >> log.log -echo ------- >> log.log -echo ------- -echo --- Build ig -echo ------- -date >> log.log -date - -# ************************************************ -# Build the IG_LAND made with the LevelDesign Tool -# ************************************************ - -# Get the primitive directory -continentdir=`cat ../../cfg/config.cfg | grep "leveldesign_igexport_continent_dir" | sed -e 's/leveldesign_igexport_continent_dir//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/;//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the primitive directories -ligo_ig_primitive_directory=`cat ../../cfg/directories.cfg | grep "ligo_ig_primitive_directory" | sed -e 's/ligo_ig_primitive_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the form directory -form_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -if ( test "$continentdir" || test "$ligo_ig_primitive_directory" ) -then - land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` - - if ( test "$land_name" ) - then - echo [Prim IG] ON - echo [Prim IG] ON >> log.log - # create cfg file - # +++++++++++++++ - - rm prim_export.cfg - echo "// prim_export.cfg" > prim_export.cfg - - echo "OutIGDir = \"ig_land_ld\";" >> prim_export.cfg - echo "ZoneWDir = \"..\\zone\\zone_welded\";" >> prim_export.cfg - - name_bank=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "SmallBank = $name_bank" >> prim_export.cfg - name_farbank=`cat ../../cfg/properties.cfg | grep "bankfar_name" | sed -e 's/bankfar_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "FarBank = $name_farbank" >> prim_export.cfg - - displacedir=`cat ../../cfg/directories.cfg | grep "displace_source_directory" | sed -e 's/displace_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "DisplaceDir = \"$dir_database/$displacedir\";" >> prim_export.cfg - - echo "CellSize = 160.0;" >> prim_export.cfg - - # Set the continent directory to export - echo "PrimDirs = {" >> prim_export.cfg - echo " $continentdir," >> prim_export.cfg - for dir in $ligo_ig_primitive_directory ; do - echo " \"$database_directory/$dir\"," >> prim_export.cfg - done - echo "};" >> prim_export.cfg - - # Set the dfn directory to export - echo "FormDir = \"$form_dir\";" >> prim_export.cfg - - # ******************* - # Launch the exporter - # ******************* - - prim_export.exe prim_export.cfg - - # ******************* - # Merge it with the IG_LAND exported from Max + elvated with heightmap - # ******************* - - # elevation of the heightmap for land_max - # ++++++++++++++++++++++++++++++++++++++++++++ - - rm ig_elevation.cfg - echo "// ig_elevation.cfg" > ig_elevation.cfg - echo "OutputIGDir = \"ig_land_max_elev\";" >> ig_elevation.cfg - echo "InputIGDir = \"ig_land_max\";" >> ig_elevation.cfg - echo "CellSize = 160.0;" >> ig_elevation.cfg - - # HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> ig_elevation.cfg - - # ZFactor1 is the heightmap factor - zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "ZFactor1 = $zf1;" >> ig_elevation.cfg - - # HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> ig_elevation.cfg - - # ZFactor2 is the heightmap factor - zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "ZFactor2 = $zf2;" >> ig_elevation.cfg - - echo "LandFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> ig_elevation.cfg - - - ig_elevation ig_elevation.cfg - - # elevation of the heightmap for land_ligo - # ++++++++++++++++++++++++++++++++++++++++++++ - - rm ig_elevation.cfg - echo "// ig_elevation.cfg" > ig_elevation.cfg - echo "OutputIGDir = \"ig_land_ligo_elev\";" >> ig_elevation.cfg - echo "InputIGDir = \"ig_land_ligo\";" >> ig_elevation.cfg - echo "CellSize = 160.0;" >> ig_elevation.cfg - - # HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> ig_elevation.cfg - - # ZFactor1 is the heightmap factor - zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "ZFactor1 = $zf1;" >> ig_elevation.cfg - - # HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> ig_elevation.cfg - - # ZFactor2 is the heightmap factor - zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "ZFactor2 = $zf2;" >> ig_elevation.cfg - - land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "LandFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> ig_elevation.cfg - - ig_elevation ig_elevation.cfg - - else - echo [Prim IG] OFF - echo [Prim IG] OFF >> log.log - fi -else - echo [Prim IG] OFF - echo [Prim IG] OFF >> log.log -fi - -# Erase ig in ig_merge_tmp and ig_land_compare - -rm ig_merge_tmp/* -rm ig_land_compare/* - -# Merge ig in ig_land_ld with ig_land_max_elev in ig_merge_tmp - -dir_current=`pwd` -cd ig_land_ld -list_ig=`ls -1 *.[iI][gG] 2> /dev/null` -cd $dir_current -for filename in $list_ig ; do - # Does this file exist in ig_land_max_elev ? - if test -e ig_land_max_elev/$filename ; then - # Yes, lets merge it - ig_add ig_merge_tmp/$filename ig_land_max_elev/$filename ig_land_ld/$filename ; - else - # No, only copy it - cp ig_land_ld/$filename ig_merge_tmp/$filename ; - fi - - # Idle - ../../idle.bat -done - -# Merge ig in ig_land_max_elev with ig_land_ld in ig_merge_tmp - -cd ig_land_max_elev -list_ig=`ls -1 *.[iI][gG] 2> /dev/null` -cd $dir_current -for filename in $list_ig ; do - # Does this file exist in ig_land_ld ? - if !(test -e ig_land_ld/$filename) then - # No, only copy it - cp ig_land_max_elev/$filename ig_merge_tmp/$filename ; - fi - - # Idle - ../../idle.bat -done - -# Merge ig in ig_merge_tmp with ig_land_ligo_elev in ig_land_compare - -cd ig_merge_tmp -list_ig=`ls -1 *.[iI][gG] 2> /dev/null` -cd $dir_current -for filename in $list_ig ; do - # Does this file exist in ig_land_ligo_elev ? - if (test -e ig_land_ligo_elev/$filename) then - # Yes, lets merge it - ig_add ig_land_compare/$filename ig_merge_tmp/$filename ig_land_ligo_elev/$filename ; - else - # No, only copy it - cp ig_merge_tmp/$filename ig_land_compare/$filename ; - fi - - # Idle - ../../idle.bat -done - -# Merge ig in ig_land_ligo_elev with ig_merge_tmp in ig_land_compare - -cd ig_land_ligo_elev -list_ig=`ls -1 *.[iI][gG] 2> /dev/null` -cd $dir_current -for filename in $list_ig ; do - # Does this file exist in ig_merge_tmp ? - if !(test -e ig_merge_tmp/$filename) then - # No, only copy it - cp ig_land_ligo_elev/$filename ig_land_compare/$filename ; - fi - - # Idle - ../../idle.bat -done - -# Compare and update - -cd ig_land_compare -list_ig=`ls -1 *.[iI][gG]` -for filename in $list_ig ; do - echo "Checking $filename for update" - if test -e ../ig_land/$filename ; then - must_update=`diff --binary -q $filename ../ig_land/$filename` ; - else - must_update=YES ; - fi - - if test -n "$must_update" ; then - echo " Updating" - cp -u -p $filename ../ig_land/$filename ; - fi - - # Idle - ../../../idle.bat -done -cd ../ig_land -list_ig=`ls -1 *.[iI][gG]` -for filename in $list_ig ; do - if !(test -e ../ig_land_compare/$filename) then - echo "Remove $filename" - rm $filename ; - fi - - # Idle - ../../../idle.bat -done -cd $dir_current - - -# ****************** -# List all the zones -# ****************** - -# Get the landscape name -landscape_name=`cat ../../cfg/config.cfg | grep "landscape_name" | sed -e 's/landscape_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Landscape name exist ? -if ( test "$landscape_name" ) -then - # If the list file exists, erase it - if ( test -f "$landscape_name"_ig.txt ) - then - rm "$landscape_name"_ig.txt - fi - - cd ig_land - for i in *.[iI][gG] ; do - # Build an ig list - if ( test -f $i ) - then - echo $i >> ../"$landscape_name"_ig.txt - else - echo >> ../"$landscape_name"_ig.txt - fi - done - cd .. - - # Idle - ../../idle.bat -fi - - +#!/bin/bash +rm log.log 2> /dev/null + +# ig_land_max: landscape IG eported from 3dsmax not elevated by the heightmap +# ig_land_max_elev: landscape IG eported from 3dsmax elevated by the heightmap +# ig_land_ligo: landscape IG found in ligo bricks not elevated by the heightmap +# ig_land_ligo_elev: landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +# ig_land_ld: landscape IG generated by the land exporter (already elevated by the land exporter) + +# ig_land: final IG directory for landscape IGs +# ig_land_compare: Tmp final IG directory for landscape IGs before comparison +# ig_other: final IG directory for village or construction IGs + +# Log error +echo ------- >> log.log +echo --- Build ig >> log.log +echo ------- >> log.log +echo ------- +echo --- Build ig +echo ------- +date >> log.log +date + +# ************************************************ +# Build the IG_LAND made with the LevelDesign Tool +# ************************************************ + +# Get the primitive directory +continentdir=`cat ../../cfg/config.cfg | grep "leveldesign_igexport_continent_dir" | sed -e 's/leveldesign_igexport_continent_dir//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/;//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the primitive directories +ligo_ig_primitive_directory=`cat ../../cfg/directories.cfg | grep "ligo_ig_primitive_directory" | sed -e 's/ligo_ig_primitive_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the form directory +form_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +if ( test "$continentdir" || test "$ligo_ig_primitive_directory" ) +then + land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` + + if ( test "$land_name" ) + then + echo [Prim IG] ON + echo [Prim IG] ON >> log.log + # create cfg file + # +++++++++++++++ + + rm prim_export.cfg + echo "// prim_export.cfg" > prim_export.cfg + + echo "OutIGDir = \"ig_land_ld\";" >> prim_export.cfg + echo "ZoneWDir = \"..\\zone\\zone_welded\";" >> prim_export.cfg + + name_bank=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "SmallBank = $name_bank" >> prim_export.cfg + name_farbank=`cat ../../cfg/properties.cfg | grep "bankfar_name" | sed -e 's/bankfar_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "FarBank = $name_farbank" >> prim_export.cfg + + displacedir=`cat ../../cfg/directories.cfg | grep "displace_source_directory" | sed -e 's/displace_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "DisplaceDir = \"$dir_database/$displacedir\";" >> prim_export.cfg + + echo "CellSize = 160.0;" >> prim_export.cfg + + # Set the continent directory to export + echo "PrimDirs = {" >> prim_export.cfg + echo " $continentdir," >> prim_export.cfg + for dir in $ligo_ig_primitive_directory ; do + echo " \"$database_directory/$dir\"," >> prim_export.cfg + done + echo "};" >> prim_export.cfg + + # Set the dfn directory to export + echo "FormDir = \"$form_dir\";" >> prim_export.cfg + + # ******************* + # Launch the exporter + # ******************* + + prim_export.exe prim_export.cfg + + # ******************* + # Merge it with the IG_LAND exported from Max + elvated with heightmap + # ******************* + + # elevation of the heightmap for land_max + # ++++++++++++++++++++++++++++++++++++++++++++ + + rm ig_elevation.cfg + echo "// ig_elevation.cfg" > ig_elevation.cfg + echo "OutputIGDir = \"ig_land_max_elev\";" >> ig_elevation.cfg + echo "InputIGDir = \"ig_land_max\";" >> ig_elevation.cfg + echo "CellSize = 160.0;" >> ig_elevation.cfg + + # HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> ig_elevation.cfg + + # ZFactor1 is the heightmap factor + zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "ZFactor1 = $zf1;" >> ig_elevation.cfg + + # HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> ig_elevation.cfg + + # ZFactor2 is the heightmap factor + zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "ZFactor2 = $zf2;" >> ig_elevation.cfg + + echo "LandFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> ig_elevation.cfg + + + ig_elevation ig_elevation.cfg + + # elevation of the heightmap for land_ligo + # ++++++++++++++++++++++++++++++++++++++++++++ + + rm ig_elevation.cfg + echo "// ig_elevation.cfg" > ig_elevation.cfg + echo "OutputIGDir = \"ig_land_ligo_elev\";" >> ig_elevation.cfg + echo "InputIGDir = \"ig_land_ligo\";" >> ig_elevation.cfg + echo "CellSize = 160.0;" >> ig_elevation.cfg + + # HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> ig_elevation.cfg + + # ZFactor1 is the heightmap factor + zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "ZFactor1 = $zf1;" >> ig_elevation.cfg + + # HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> ig_elevation.cfg + + # ZFactor2 is the heightmap factor + zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "ZFactor2 = $zf2;" >> ig_elevation.cfg + + land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "LandFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> ig_elevation.cfg + + ig_elevation ig_elevation.cfg + + else + echo [Prim IG] OFF + echo [Prim IG] OFF >> log.log + fi +else + echo [Prim IG] OFF + echo [Prim IG] OFF >> log.log +fi + +# Erase ig in ig_merge_tmp and ig_land_compare + +rm ig_merge_tmp/* +rm ig_land_compare/* + +# Merge ig in ig_land_ld with ig_land_max_elev in ig_merge_tmp + +dir_current=`pwd` +cd ig_land_ld +list_ig=`ls -1 *.[iI][gG] 2> /dev/null` +cd $dir_current +for filename in $list_ig ; do + # Does this file exist in ig_land_max_elev ? + if test -e ig_land_max_elev/$filename ; then + # Yes, lets merge it + ig_add ig_merge_tmp/$filename ig_land_max_elev/$filename ig_land_ld/$filename ; + else + # No, only copy it + cp ig_land_ld/$filename ig_merge_tmp/$filename ; + fi + + # Idle + ../../idle.bat +done + +# Merge ig in ig_land_max_elev with ig_land_ld in ig_merge_tmp + +cd ig_land_max_elev +list_ig=`ls -1 *.[iI][gG] 2> /dev/null` +cd $dir_current +for filename in $list_ig ; do + # Does this file exist in ig_land_ld ? + if !(test -e ig_land_ld/$filename) then + # No, only copy it + cp ig_land_max_elev/$filename ig_merge_tmp/$filename ; + fi + + # Idle + ../../idle.bat +done + +# Merge ig in ig_merge_tmp with ig_land_ligo_elev in ig_land_compare + +cd ig_merge_tmp +list_ig=`ls -1 *.[iI][gG] 2> /dev/null` +cd $dir_current +for filename in $list_ig ; do + # Does this file exist in ig_land_ligo_elev ? + if (test -e ig_land_ligo_elev/$filename) then + # Yes, lets merge it + ig_add ig_land_compare/$filename ig_merge_tmp/$filename ig_land_ligo_elev/$filename ; + else + # No, only copy it + cp ig_merge_tmp/$filename ig_land_compare/$filename ; + fi + + # Idle + ../../idle.bat +done + +# Merge ig in ig_land_ligo_elev with ig_merge_tmp in ig_land_compare + +cd ig_land_ligo_elev +list_ig=`ls -1 *.[iI][gG] 2> /dev/null` +cd $dir_current +for filename in $list_ig ; do + # Does this file exist in ig_merge_tmp ? + if !(test -e ig_merge_tmp/$filename) then + # No, only copy it + cp ig_land_ligo_elev/$filename ig_land_compare/$filename ; + fi + + # Idle + ../../idle.bat +done + +# Compare and update + +cd ig_land_compare +list_ig=`ls -1 *.[iI][gG]` +for filename in $list_ig ; do + echo "Checking $filename for update" + if test -e ../ig_land/$filename ; then + must_update=`diff --binary -q $filename ../ig_land/$filename` ; + else + must_update=YES ; + fi + + if test -n "$must_update" ; then + echo " Updating" + cp -u -p $filename ../ig_land/$filename ; + fi + + # Idle + ../../../idle.bat +done +cd ../ig_land +list_ig=`ls -1 *.[iI][gG]` +for filename in $list_ig ; do + if !(test -e ../ig_land_compare/$filename) then + echo "Remove $filename" + rm $filename ; + fi + + # Idle + ../../../idle.bat +done +cd $dir_current + + +# ****************** +# List all the zones +# ****************** + +# Get the landscape name +landscape_name=`cat ../../cfg/config.cfg | grep "landscape_name" | sed -e 's/landscape_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Landscape name exist ? +if ( test "$landscape_name" ) +then + # If the list file exists, erase it + if ( test -f "$landscape_name"_ig.txt ) + then + rm "$landscape_name"_ig.txt + fi + + cd ig_land + for i in *.[iI][gG] ; do + # Build an ig list + if ( test -f $i ) + then + echo $i >> ../"$landscape_name"_ig.txt + else + echo >> ../"$landscape_name"_ig.txt + fi + done + cd .. + + # Idle + ../../idle.bat +fi + + diff --git a/nel/tools/3d/build_gamedata/processes/ig/sh/export.sh b/nel/tools/3d/build_gamedata/processes/ig/sh/export.sh index 84c043e48..c641296ec 100644 --- a/nel/tools/3d/build_gamedata/processes/ig/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/ig/sh/export.sh @@ -1,90 +1,90 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export ig files (.ig) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "ig_export_timeout" | sed -e 's/ig_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the ig directories -ig_land_source_directories=`cat ../../cfg/directories.cfg | grep "ig_land_source_directory" | sed -e 's/ig_land_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the ig directories -ig_other_source_directories=`cat ../../cfg/directories.cfg | grep "ig_other_source_directory" | sed -e 's/ig_other_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export ig >> log.log -echo ------- >> log.log -echo ------- -echo --- Export ig -echo ------- -date >> log.log -date - -# For each directoy - -# List landscape ig - - -for i in $ig_land_source_directories ; do - # Copy the script - cat maxscript/ig_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/ig/log.log&g" | sed -e "s&ig_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/ig/tag&g" | sed -e "s&output_directory_ig&$build_gamedata_directory/processes/ig/ig_land_max&g" > $max_directory/scripts/ig_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - - - - -for i in $ig_other_source_directories ; do - # Copy the script - cat maxscript/ig_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/ig/log.log&g" | sed -e "s&ig_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/ig/tag&g" | sed -e "s&output_directory_ig&$build_gamedata_directory/processes/ig/ig_other&g" > $max_directory/scripts/ig_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export ig files (.ig) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "ig_export_timeout" | sed -e 's/ig_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the ig directories +ig_land_source_directories=`cat ../../cfg/directories.cfg | grep "ig_land_source_directory" | sed -e 's/ig_land_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the ig directories +ig_other_source_directories=`cat ../../cfg/directories.cfg | grep "ig_other_source_directory" | sed -e 's/ig_other_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export ig >> log.log +echo ------- >> log.log +echo ------- +echo --- Export ig +echo ------- +date >> log.log +date + +# For each directoy + +# List landscape ig + + +for i in $ig_land_source_directories ; do + # Copy the script + cat maxscript/ig_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/ig/log.log&g" | sed -e "s&ig_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/ig/tag&g" | sed -e "s&output_directory_ig&$build_gamedata_directory/processes/ig/ig_land_max&g" > $max_directory/scripts/ig_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + + + + +for i in $ig_other_source_directories ; do + # Copy the script + cat maxscript/ig_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/ig/log.log&g" | sed -e "s&ig_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/ig/tag&g" | sed -e "s&output_directory_ig&$build_gamedata_directory/processes/ig/ig_other&g" > $max_directory/scripts/ig_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript ig_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/ig/sh/install.sh b/nel/tools/3d/build_gamedata/processes/ig/sh/install.sh index 430326d2c..056974dac 100644 --- a/nel/tools/3d/build_gamedata/processes/ig/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/ig/sh/install.sh @@ -1,30 +1,30 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install ig in the client data - -# Get the ig install directory -ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the landscape name -landscape_name=`cat ../../cfg/config.cfg | grep "landscape_name" | sed -e 's/landscape_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install Ig >> log.log -echo ------- >> log.log -echo ------- -echo --- Install Ig -echo ------- -date >> log.log -date - -cp -u -p "$landscape_name"_ig.txt $client_directory/$ig_install_directory 2>> log.log - -# Do not copy ig_land, because zone process will copy zone ig lighted versions into client directory. -#cp -u -p ig_land/*.[iI][gG] $client_directory/$ig_install_directory 2>> log.log -# Do not copy ig_other, because ig_light process will copy ig lighted versions into client directory. -#cp -u -p ig_other/*.[iI][gG] $client_directory/$ig_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install ig in the client data + +# Get the ig install directory +ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the landscape name +landscape_name=`cat ../../cfg/config.cfg | grep "landscape_name" | sed -e 's/landscape_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install Ig >> log.log +echo ------- >> log.log +echo ------- +echo --- Install Ig +echo ------- +date >> log.log +date + +cp -u -p "$landscape_name"_ig.txt $client_directory/$ig_install_directory 2>> log.log + +# Do not copy ig_land, because zone process will copy zone ig lighted versions into client directory. +#cp -u -p ig_land/*.[iI][gG] $client_directory/$ig_install_directory 2>> log.log +# Do not copy ig_other, because ig_light process will copy ig lighted versions into client directory. +#cp -u -p ig_other/*.[iI][gG] $client_directory/$ig_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/ig_light/sh/install.sh b/nel/tools/3d/build_gamedata/processes/ig_light/sh/install.sh index 2d1e823df..9392454ec 100644 --- a/nel/tools/3d/build_gamedata/processes/ig_light/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/ig_light/sh/install.sh @@ -1,23 +1,23 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install ig in the client data - -# Get the ig install directory -ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install Lighted Ig >> log.log -echo ------- >> log.log -echo ------- -echo --- Install Lighted Ig -echo ------- -date >> log.log -date - -cp -u -p -R ig_other_lighted/. $client_directory/$ig_install_directory 2>> log.log - +#!/bin/bash +rm log.log 2> /dev/null + +# Install ig in the client data + +# Get the ig install directory +ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install Lighted Ig >> log.log +echo ------- >> log.log +echo ------- +echo --- Install Lighted Ig +echo ------- +date >> log.log +date + +cp -u -p -R ig_other_lighted/. $client_directory/$ig_install_directory 2>> log.log + diff --git a/nel/tools/3d/build_gamedata/processes/interface/sh/build.sh b/nel/tools/3d/build_gamedata/processes/interface/sh/build.sh index d7e4c0b4d..d472dbc85 100644 --- a/nel/tools/3d/build_gamedata/processes/interface/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/interface/sh/build.sh @@ -1,60 +1,60 @@ -#!/bin/bash -rm log.log 2> /dev/null - - -# *** Build interface - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the interface directories -interface_source_directories=`cat ../../cfg/directories.cfg | grep "interface_source_directories" | sed -e 's/interface_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the interface directories to compress in one DXTC only -interface_source_dxtc_directories=`cat ../../cfg/directories.cfg | grep "interface_source_dxtc_directories" | sed -e 's/interface_source_dxtc_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Build interface >> log.log -echo ------- >> log.log -echo ------- -echo --- Build interface -echo ------- -date >> log.log -date - -# For each interface directory -for i in $interface_source_directories ; do - # Copy - niouname=`echo $i | sed -e 's&/&_&g'` - rm tga_tmp/*.[tT][gG][aA] - cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log - build_interface.exe tga/texture_$niouname.tga tga_tmp - - # Idle - ../../idle.bat -done - - -# For each interface directory to compress in one DXTC -rm tga_tmp/*.[tT][gG][aA] -for i in $interface_source_dxtc_directories ; do - # Copy - cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log -done - -# build all files in tga_tmp into one tga. Let the OpenGL compress it at runTime (better result for some important cases) -build_interface.exe tga/texture_interfaces_dxtc.tga tga_tmp -# DO NOT COMPRESS ../../bin/tga2dds tga_tmp/texture_interfaces_dxtc.tga -o tga/texture_interfaces_dxtc.dds -a 5 - - -# Compress animation. Important to avoid 'memory fragmentation' -mv -u 3d/*.[aA][nN][iI][mM] anim_tmp 2>> log.log -anim_builder.exe anim_tmp 3d ../../cfg/properties.cfg - - - -# Idle -../../idle.bat - - +#!/bin/bash +rm log.log 2> /dev/null + + +# *** Build interface + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the interface directories +interface_source_directories=`cat ../../cfg/directories.cfg | grep "interface_source_directories" | sed -e 's/interface_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the interface directories to compress in one DXTC only +interface_source_dxtc_directories=`cat ../../cfg/directories.cfg | grep "interface_source_dxtc_directories" | sed -e 's/interface_source_dxtc_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Build interface >> log.log +echo ------- >> log.log +echo ------- +echo --- Build interface +echo ------- +date >> log.log +date + +# For each interface directory +for i in $interface_source_directories ; do + # Copy + niouname=`echo $i | sed -e 's&/&_&g'` + rm tga_tmp/*.[tT][gG][aA] + cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log + build_interface.exe tga/texture_$niouname.tga tga_tmp + + # Idle + ../../idle.bat +done + + +# For each interface directory to compress in one DXTC +rm tga_tmp/*.[tT][gG][aA] +for i in $interface_source_dxtc_directories ; do + # Copy + cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log +done + +# build all files in tga_tmp into one tga. Let the OpenGL compress it at runTime (better result for some important cases) +build_interface.exe tga/texture_interfaces_dxtc.tga tga_tmp +# DO NOT COMPRESS ../../bin/tga2dds tga_tmp/texture_interfaces_dxtc.tga -o tga/texture_interfaces_dxtc.dds -a 5 + + +# Compress animation. Important to avoid 'memory fragmentation' +mv -u 3d/*.[aA][nN][iI][mM] anim_tmp 2>> log.log +anim_builder.exe anim_tmp 3d ../../cfg/properties.cfg + + + +# Idle +../../idle.bat + + diff --git a/nel/tools/3d/build_gamedata/processes/interface/sh/export.sh b/nel/tools/3d/build_gamedata/processes/interface/sh/export.sh index be85e0e49..0f36bc621 100644 --- a/nel/tools/3d/build_gamedata/processes/interface/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/interface/sh/export.sh @@ -1,62 +1,62 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Bin -tga_2_dds='tga2dds.exe' - -# *** Export interface tile (.tga) - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the interface fullscreen directories -interface_fullscreen_directories=`cat ../../cfg/directories.cfg | grep "interface_fullscreen_directories" | sed -e 's/interface_fullscreen_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the interface 3d directories -interface_3d_directories=`cat ../../cfg/directories.cfg | grep "interface_3d_directories" | sed -e 's/interface_3d_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export interface >> log.log -echo ------- >> log.log -echo ------- -echo --- Export interface -echo ------- -date >> log.log -date - -# For each interface fullscreen directory compress independently all in dds -rm tga_tmp/*.[tT][gG][aA] -for i in $interface_fullscreen_directories; do - # Copy - cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log - - # Idle - ../../idle.bat -done - -for i in tga_tmp/*.[tT][gG][aA] ; do - - # Destination file - dest=`echo $i | sed -e 's/tga_tmp/tga/g'` - dest=`echo $dest | sed -e 's/\.[tT][gG][aA]/.dds/g'` - - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - # Convert - $tga_2_dds $i -o $dest -a 5 2>> log.log - fi - - # Idle - ../../idle.bat -done - - -# For each interface 3d directory -for i in $interface_3d_directories; do - # Copy - cp -u -p $database_directory/$i/* 3d 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# Bin +tga_2_dds='tga2dds.exe' + +# *** Export interface tile (.tga) + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the interface fullscreen directories +interface_fullscreen_directories=`cat ../../cfg/directories.cfg | grep "interface_fullscreen_directories" | sed -e 's/interface_fullscreen_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the interface 3d directories +interface_3d_directories=`cat ../../cfg/directories.cfg | grep "interface_3d_directories" | sed -e 's/interface_3d_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export interface >> log.log +echo ------- >> log.log +echo ------- +echo --- Export interface +echo ------- +date >> log.log +date + +# For each interface fullscreen directory compress independently all in dds +rm tga_tmp/*.[tT][gG][aA] +for i in $interface_fullscreen_directories; do + # Copy + cp -u -p $database_directory/$i/*.[tT][gG][aA] tga_tmp 2>> log.log + + # Idle + ../../idle.bat +done + +for i in tga_tmp/*.[tT][gG][aA] ; do + + # Destination file + dest=`echo $i | sed -e 's/tga_tmp/tga/g'` + dest=`echo $dest | sed -e 's/\.[tT][gG][aA]/.dds/g'` + + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + # Convert + $tga_2_dds $i -o $dest -a 5 2>> log.log + fi + + # Idle + ../../idle.bat +done + + +# For each interface 3d directory +for i in $interface_3d_directories; do + # Copy + cp -u -p $database_directory/$i/* 3d 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/interface/sh/install.sh b/nel/tools/3d/build_gamedata/processes/interface/sh/install.sh index bf8e62f95..86e4df5b4 100644 --- a/nel/tools/3d/build_gamedata/processes/interface/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/interface/sh/install.sh @@ -1,24 +1,24 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the interface in the client data - -# Get the interface install directory -interface_install_directory=`cat ../../cfg/directories.cfg | grep "interface_install_directory" | sed -e 's/interface_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install interface >> log.log -echo ------- >> log.log -echo ------- -echo --- Install interface -echo ------- -date >> log.log -date - -cp -u -p -R tga/. $client_directory/$interface_install_directory 2>> log.log -cp -u -p -R 3d/. $client_directory/$interface_install_directory 2>> log.log - +#!/bin/bash +rm log.log 2> /dev/null + +# Install the interface in the client data + +# Get the interface install directory +interface_install_directory=`cat ../../cfg/directories.cfg | grep "interface_install_directory" | sed -e 's/interface_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install interface >> log.log +echo ------- >> log.log +echo ------- +echo --- Install interface +echo ------- +date >> log.log +date + +cp -u -p -R tga/. $client_directory/$interface_install_directory 2>> log.log +cp -u -p -R 3d/. $client_directory/$interface_install_directory 2>> log.log + diff --git a/nel/tools/3d/build_gamedata/processes/ligo/sh/build.sh b/nel/tools/3d/build_gamedata/processes/ligo/sh/build.sh index 289d625c3..1cfddec61 100644 --- a/nel/tools/3d/build_gamedata/processes/ligo/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/ligo/sh/build.sh @@ -1,202 +1,202 @@ -#!/bin/bash -rm log.log 2> /dev/null - -echo > log.log - -# ******************** -# Make the config file -# ******************** - -exec_timeout='exec_timeout.exe' - -# Get the timeout -land_exporter_timeout=`cat ../../cfg/config.cfg | grep "ligo_build_timeout" | sed -e 's/ligo_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -rm land_exporter.cfg -echo "// land_exporter.cfg" > land_exporter.cfg - -# OutZoneDir is Where to put all .zone generated - -#dir_gamedata=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -#echo "OutZoneDir = \"$dir_gamedata/processes/ligo/output\";" >> land_exporter.cfg -echo "OutZoneDir = \"output\";" >> land_exporter.cfg -echo "OutIGDir = \"../ig/ig_land_ligo\";" >> land_exporter.cfg -echo "AdditionnalIGOutDir = \"../ig/ig_other\";" >> land_exporter.cfg - -# RefZoneDir is Where the reference zones are - -dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -dir_ligobricks=`cat ../../cfg/directories.cfg | grep "ligo_bricks_directory" | sed -e 's/ligo_bricks_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -dir_dfn=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -continent_file=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//' | sed -e 's/ //g' | sed -e 's/=//g'` -dir_world=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -# dir_continents=`cat ../../cfg/site.cfg | grep "continents_directory" | sed -e 's/continents_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - - - - - - -echo "RefZoneDir = \"$dir_ligobricks/zones\";" >> land_exporter.cfg -echo "RefIGDir = \"$dir_ligobricks/igs\";" >> land_exporter.cfg -echo "AdditionnalIGInDir = \"$dir_ligobricks/igs\";" >> land_exporter.cfg -# echo "ContinentsDir = \"$dir_continents\";" >> land_exporter.cfg -echo "ContinentsDir = \"$dir_world\";" >> land_exporter.cfg - - - - -# LigoBankDir is Where all .ligozone are (those used by the .land) - -echo "LigoBankDir = \"$dir_ligobricks/zoneligos\";" >> land_exporter.cfg - -# TileBankFile is the .bank file (used to know if a tile is oriented and the like) - -name_bank=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "TileBankFile = $name_bank" >> land_exporter.cfg - -# ColorMapFile - -cmf=`cat ../../cfg/config.cfg | grep "ligo_export_colormap" | sed -e 's/ligo_export_colormap//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "ColorMapFile = \"$dir_database/$dir_ligosrc/$cmf\";" >> land_exporter.cfg - -# HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - -hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> land_exporter.cfg - -# ZFactor1 is the heightmap factor - -zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "ZFactor1 = $zf1;" >> land_exporter.cfg - -# HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) - -hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> land_exporter.cfg - -# ZFactor2 is the heightmap factor - -zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "ZFactor2 = $zf2;" >> land_exporter.cfg - -# ZoneLight is Roughly light the zone (0-none, 1-patch, 2-noise) - -echo "ZoneLight = 0;" >> land_exporter.cfg - -# CellSize is the size of the cell (zone size) in meter - -echo "CellSize = 160;" >> land_exporter.cfg - -# Threshild is the weld threshold in meter - -echo "Threshold = 1;" >> land_exporter.cfg - -# Where to take dfn files -echo "DFNDir = \"$dir_dfn\";" >> land_exporter.cfg - -# CMB input directory -echo "RefCMBDir = \"$dir_ligobricks/cmb\";" >> land_exporter.cfg - -# CMB output directory -echo "OutCMBDir = \"../rbank/cmb\";" >> land_exporter.cfg - -#input .continent file -echo "ContinentFile = \"$dir_world/$continent_file\";" >> land_exporter.cfg - -# Force export of collisions and additionnal igs -echo "ExportCollisions = 1;" >> land_exporter.cfg -echo "ExportAdditionnalIGs = 1;" >> land_exporter.cfg - - - -# ZoneRegionFile is the .land to compute - -dir_current=`pwd` - -land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` -echo "ZoneRegionFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> land_exporter.cfg - -# if there is no .land then do not generate all zones and zone welded - -if test -z "$land_name" ; then - echo No .land set -- Exiting -- - exit; -fi - -# ******************* -# launch the exporter -# ******************* - -echo ------- >> log.log -echo --- Generate ligo zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Generate ligo zone -echo ------- -date >> log.log -date - -echo Exporting -$exec_timeout $land_exporter_timeout land_export.exe land_exporter.cfg - -# rename *.[zZ][oO][nN][eE][lL] *.[zZ][oO][nN][eE] -# script is just too slow to do renaming... And we can't call directly dos command - -cd output -../sh/renametozone.bat -cd .. - -# ************** -# Copy the zones -# ************** - -cd ../zone -mkdir zone_exported 2> /dev/null - -# Try to copy ligo zone if any -# **************************** - -ligo_flag=`cat ../../cfg/config.cfg | grep "process_to_complete" | grep "ligo"` - -dir_current=`pwd` -cd ../ligo/output -list_zone=`ls -1 *.[zZ][oO][nN][eE]*` -for filename in $list_zone ; do - echo "Checking $filename for update" - if test -e ../../zone/zone_exported/$filename ; then - must_update=`diff --binary -q $filename ../../zone/zone_exported/$filename` ; - else - must_update=YES ; - fi - - if test -n "$must_update" ; then - echo " Updating" - cp -u -p $filename ../../zone/zone_exported/$filename ; - fi - - # Idle - ../../../idle.bat -done -cd $dir_current - -# delete files only present in the zone_exported directory - -if ( test "$ligo_flag" ) -then - cd ./zone_exported - list_zone=`ls -1 *.[zZ][oO][nN][eE]*` - for filename in $list_zone ; do - if test -e ../../ligo/output/$filename ; then - must_update=NO ; - else - echo "Removing $filename" - rm $filename ; - fi - - # Idle - ../../../idle.bat - done - cd .. -fi +#!/bin/bash +rm log.log 2> /dev/null + +echo > log.log + +# ******************** +# Make the config file +# ******************** + +exec_timeout='exec_timeout.exe' + +# Get the timeout +land_exporter_timeout=`cat ../../cfg/config.cfg | grep "ligo_build_timeout" | sed -e 's/ligo_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +rm land_exporter.cfg +echo "// land_exporter.cfg" > land_exporter.cfg + +# OutZoneDir is Where to put all .zone generated + +#dir_gamedata=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +#echo "OutZoneDir = \"$dir_gamedata/processes/ligo/output\";" >> land_exporter.cfg +echo "OutZoneDir = \"output\";" >> land_exporter.cfg +echo "OutIGDir = \"../ig/ig_land_ligo\";" >> land_exporter.cfg +echo "AdditionnalIGOutDir = \"../ig/ig_other\";" >> land_exporter.cfg + +# RefZoneDir is Where the reference zones are + +dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +dir_ligobricks=`cat ../../cfg/directories.cfg | grep "ligo_bricks_directory" | sed -e 's/ligo_bricks_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +dir_dfn=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +continent_file=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//' | sed -e 's/ //g' | sed -e 's/=//g'` +dir_world=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +# dir_continents=`cat ../../cfg/site.cfg | grep "continents_directory" | sed -e 's/continents_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + + + + + + +echo "RefZoneDir = \"$dir_ligobricks/zones\";" >> land_exporter.cfg +echo "RefIGDir = \"$dir_ligobricks/igs\";" >> land_exporter.cfg +echo "AdditionnalIGInDir = \"$dir_ligobricks/igs\";" >> land_exporter.cfg +# echo "ContinentsDir = \"$dir_continents\";" >> land_exporter.cfg +echo "ContinentsDir = \"$dir_world\";" >> land_exporter.cfg + + + + +# LigoBankDir is Where all .ligozone are (those used by the .land) + +echo "LigoBankDir = \"$dir_ligobricks/zoneligos\";" >> land_exporter.cfg + +# TileBankFile is the .bank file (used to know if a tile is oriented and the like) + +name_bank=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "TileBankFile = $name_bank" >> land_exporter.cfg + +# ColorMapFile + +cmf=`cat ../../cfg/config.cfg | grep "ligo_export_colormap" | sed -e 's/ligo_export_colormap//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "ColorMapFile = \"$dir_database/$dir_ligosrc/$cmf\";" >> land_exporter.cfg + +# HeightMapFile1 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + +hmf1=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap1" | sed -e 's/ligo_export_heightmap1//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "HeightMapFile1 = \"$dir_database/$dir_ligosrc/$hmf1\";" >> land_exporter.cfg + +# ZFactor1 is the heightmap factor + +zf1=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor1" | sed -e 's/ligo_export_zfactor1//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "ZFactor1 = $zf1;" >> land_exporter.cfg + +# HeightMapFile2 is the grayscale .tga file (127 is 0, 0 is -127*ZFactor and 255 is +128*ZFactor) + +hmf2=`cat ../../cfg/config.cfg | grep "ligo_export_heightmap2" | sed -e 's/ligo_export_heightmap2//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "HeightMapFile2 = \"$dir_database/$dir_ligosrc/$hmf2\";" >> land_exporter.cfg + +# ZFactor2 is the heightmap factor + +zf2=`cat ../../cfg/config.cfg | grep "ligo_export_zfactor2" | sed -e 's/ligo_export_zfactor2//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "ZFactor2 = $zf2;" >> land_exporter.cfg + +# ZoneLight is Roughly light the zone (0-none, 1-patch, 2-noise) + +echo "ZoneLight = 0;" >> land_exporter.cfg + +# CellSize is the size of the cell (zone size) in meter + +echo "CellSize = 160;" >> land_exporter.cfg + +# Threshild is the weld threshold in meter + +echo "Threshold = 1;" >> land_exporter.cfg + +# Where to take dfn files +echo "DFNDir = \"$dir_dfn\";" >> land_exporter.cfg + +# CMB input directory +echo "RefCMBDir = \"$dir_ligobricks/cmb\";" >> land_exporter.cfg + +# CMB output directory +echo "OutCMBDir = \"../rbank/cmb\";" >> land_exporter.cfg + +#input .continent file +echo "ContinentFile = \"$dir_world/$continent_file\";" >> land_exporter.cfg + +# Force export of collisions and additionnal igs +echo "ExportCollisions = 1;" >> land_exporter.cfg +echo "ExportAdditionnalIGs = 1;" >> land_exporter.cfg + + + +# ZoneRegionFile is the .land to compute + +dir_current=`pwd` + +land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` +echo "ZoneRegionFile = \"$dir_database/$dir_ligosrc/$land_name\";" >> land_exporter.cfg + +# if there is no .land then do not generate all zones and zone welded + +if test -z "$land_name" ; then + echo No .land set -- Exiting -- + exit; +fi + +# ******************* +# launch the exporter +# ******************* + +echo ------- >> log.log +echo --- Generate ligo zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Generate ligo zone +echo ------- +date >> log.log +date + +echo Exporting +$exec_timeout $land_exporter_timeout land_export.exe land_exporter.cfg + +# rename *.[zZ][oO][nN][eE][lL] *.[zZ][oO][nN][eE] +# script is just too slow to do renaming... And we can't call directly dos command + +cd output +../sh/renametozone.bat +cd .. + +# ************** +# Copy the zones +# ************** + +cd ../zone +mkdir zone_exported 2> /dev/null + +# Try to copy ligo zone if any +# **************************** + +ligo_flag=`cat ../../cfg/config.cfg | grep "process_to_complete" | grep "ligo"` + +dir_current=`pwd` +cd ../ligo/output +list_zone=`ls -1 *.[zZ][oO][nN][eE]*` +for filename in $list_zone ; do + echo "Checking $filename for update" + if test -e ../../zone/zone_exported/$filename ; then + must_update=`diff --binary -q $filename ../../zone/zone_exported/$filename` ; + else + must_update=YES ; + fi + + if test -n "$must_update" ; then + echo " Updating" + cp -u -p $filename ../../zone/zone_exported/$filename ; + fi + + # Idle + ../../../idle.bat +done +cd $dir_current + +# delete files only present in the zone_exported directory + +if ( test "$ligo_flag" ) +then + cd ./zone_exported + list_zone=`ls -1 *.[zZ][oO][nN][eE]*` + for filename in $list_zone ; do + if test -e ../../ligo/output/$filename ; then + must_update=NO ; + else + echo "Removing $filename" + rm $filename ; + fi + + # Idle + ../../../idle.bat + done + cd .. +fi diff --git a/nel/tools/3d/build_gamedata/processes/ligo/sh/export.sh b/nel/tools/3d/build_gamedata/processes/ligo/sh/export.sh index 4bf0f4d15..080bac484 100644 --- a/nel/tools/3d/build_gamedata/processes/ligo/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/ligo/sh/export.sh @@ -1,72 +1,72 @@ -#!/bin/bash -rm log.log 2> /dev/null - -echo > log.log - -# *** Export ligo zone files from Max *** -# *** ******************************* *** - -echo ------- >> log.log -echo --- Export ligo zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Export ligo zone -echo ------- -date >> log.log -date - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "ligo_export_timeout" | sed -e 's/ligo_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get current directory -dir_gamedata=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` -dir_gamedata_maxscript=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the bank filename -bank_filename=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` -bankfar_filename=`cat ../../cfg/properties.cfg | grep "bankfar_name" | sed -e 's/bankfar_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` - -# Copy the bank file -cp $bank_filename smallbank/ligo.smallbank 2>> log.log -cp $bankfar_filename smallbank/ligo.farbank 2>> log.log - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# delete ini file - -rm $max_directory/plugcfg/nelligo.ini -# echo "$max_directory/plugcfg/nelligo.ini" >> log.log - -# create the ini file - -echo "[LigoConfig]" > $max_directory/plugcfg/nelligo.ini - -# copy the ligo export script -cat maxscript/nel_ligo_export.ms | sed -e "s&output_directory_tag&$dir_gamedata_maxscript/processes/ligo/tag&g" | sed -e "s&output_logfile&$dir_gamedata_maxscript/processes/ligo/log.log&g" | sed -e "s&bankFilename&$dir_gamedata_maxscript/processes/ligo/smallbank/ligo.smallbank&g" > $max_directory/scripts/nel_ligo_export.ms - -dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` -dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` - -echo "LigoPath=$dir_database\\$dir_ligosrc\\max\\" >> $max_directory/plugcfg/nelligo.ini -#echo "LigoExportPath=$dir_database\\$dir_ligosrc\\" >> $max_directory/plugcfg/nelligo.ini - -echo "LigoExportPath=$dir_gamedata\\processes\\ligo\\" >> $max_directory/plugcfg/nelligo.ini - -# export only if no .land set - -land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` -ligo_export_one_pass=`cat ../../cfg/config.cfg | grep "ligo_export_one_pass" | sed -e 's/ligo_export_one_pass//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` - -if [ -z "$land_name" -o "$ligo_export_one_pass" == "1" ] ; then - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn -fi +#!/bin/bash +rm log.log 2> /dev/null + +echo > log.log + +# *** Export ligo zone files from Max *** +# *** ******************************* *** + +echo ------- >> log.log +echo --- Export ligo zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Export ligo zone +echo ------- +date >> log.log +date + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "ligo_export_timeout" | sed -e 's/ligo_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get current directory +dir_gamedata=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` +dir_gamedata_maxscript=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the bank filename +bank_filename=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` +bankfar_filename=`cat ../../cfg/properties.cfg | grep "bankfar_name" | sed -e 's/bankfar_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` + +# Copy the bank file +cp $bank_filename smallbank/ligo.smallbank 2>> log.log +cp $bankfar_filename smallbank/ligo.farbank 2>> log.log + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# delete ini file + +rm $max_directory/plugcfg/nelligo.ini +# echo "$max_directory/plugcfg/nelligo.ini" >> log.log + +# create the ini file + +echo "[LigoConfig]" > $max_directory/plugcfg/nelligo.ini + +# copy the ligo export script +cat maxscript/nel_ligo_export.ms | sed -e "s&output_directory_tag&$dir_gamedata_maxscript/processes/ligo/tag&g" | sed -e "s&output_logfile&$dir_gamedata_maxscript/processes/ligo/log.log&g" | sed -e "s&bankFilename&$dir_gamedata_maxscript/processes/ligo/smallbank/ligo.smallbank&g" > $max_directory/scripts/nel_ligo_export.ms + +dir_database=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` +dir_ligosrc=`cat ../../cfg/directories.cfg | grep "ligo_source_directory" | sed -e 's/ligo_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's&\/&\\\&g'` + +echo "LigoPath=$dir_database\\$dir_ligosrc\\max\\" >> $max_directory/plugcfg/nelligo.ini +#echo "LigoExportPath=$dir_database\\$dir_ligosrc\\" >> $max_directory/plugcfg/nelligo.ini + +echo "LigoExportPath=$dir_gamedata\\processes\\ligo\\" >> $max_directory/plugcfg/nelligo.ini + +# export only if no .land set + +land_name=`cat ../../cfg/config.cfg | grep "ligo_export_land" | sed -e 's/ligo_export_land//' | sed -e 's/ //g' | sed -e 's/=//g'` +ligo_export_one_pass=`cat ../../cfg/config.cfg | grep "ligo_export_one_pass" | sed -e 's/ligo_export_one_pass//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` + +if [ -z "$land_name" -o "$ligo_export_one_pass" == "1" ] ; then + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript nel_ligo_export.ms -q -mi -vn +fi diff --git a/nel/tools/3d/build_gamedata/processes/map/sh/build.sh b/nel/tools/3d/build_gamedata/processes/map/sh/build.sh index 626767ac5..1c57da67e 100644 --- a/nel/tools/3d/build_gamedata/processes/map/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/map/sh/build.sh @@ -1,140 +1,140 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Build map files (.tga / .dds) - -# Bin -tga_2_dds='tga2dds.exe' - -# Log error -echo ------- > log.log -echo --- Build map >> log.log -echo ------- >> log.log -echo ------- -echo --- Build map -echo ------- -date >> log.log -date - - -#*** Build panoply files (.tga / .dds), and copy the result in the tga directory - -# Copy panoply containt into cache if the process as been stopped before the end of build. -echo Copy panoply into cache -cp -u -p -R panoply/. cache 2>> log.log -echo Remove panoply directory -rm -r panoply 2>> log.log -echo Copy hlsinfo into cache -cp -u -p -R hlsinfo/. cache 2>> log.log -echo Remove hlsinfo directory -rm -r hlsinfo 2>> log.log - -mkdir panoply -mkdir hlsinfo - -# Bin -panoply_maker='panoply_maker.exe' - -# Log error -echo ------- > log.log -echo --- Build panoply >> log.log -echo ------- >> log.log -echo ------- -echo --- Build panoply -echo ------- -date >> log.log -date - -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Reduce bitmap size factor -reduce_bitmap_factor=`cat ../../cfg/config.cfg | grep "reduce_bitmap_factor" | sed -e 's/reduce_bitmap_factor//' | sed -e 's/ //g' | sed -e 's/=//g'` - -panoply_file_list=`cat ../../cfg/config.cfg | grep "panoply_file_list" | sed -e 's/panoply_file_list//' | sed -e 's/ //g' | sed -e 's/=//g'` -if test "$panoply_file_list" ; then - rm $panoply_file_list - panoply_config_file=`cat ../../cfg/directories.cfg | grep "panoply_config_file" | sed -e 's/panoply_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` - for psource in $panoply_config_file ; do - cp $database_directory/$psource current_panoply.cfg - echo "output_path=\"panoply\";" >> current_panoply.cfg - echo "cache_path=\"cache\";" >> current_panoply.cfg - panoply_maker.exe current_panoply.cfg - - # Idle - ../../idle.bat - done - ls panoply >> $panoply_file_list -fi - -# For each directoy -for i in tga/*.[tT][gG][aA] ; do - - # Destination file - dest=`echo $i | sed -e 's/[tT][gG][aA]/dds/' | sed -e 's/\.[tT][gG][aA]/.dds/g'` - dds=`echo $i | sed -e 's/\.[tT][gG][aA]/.dds/g'` - - # Convert the lightmap in 16 bits mode - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - # Copy the dds file - if (test -f $dds) - then - cp $dds $dest - fi - - # Convert - $tga_2_dds $i -o $dest -m -r$reduce_bitmap_factor 2>> log.log - fi - - # Idle - ../../idle.bat -done - -for i in panoply/*.[tT][gG][aA] ; do - - # Destination file - dest=`echo $i | sed -e 's%panoply/%dds/%g' | sed -e 's/[tT][gG][aA]/dds/g'` - dds=`echo $i | sed -e 's/\.[tT][gG][aA]/.dds/g'` - - # Convert the lightmap in 16 bits mode - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - # Copy the dds file - if (test -f $dds) - then - cp $dds $dest - fi - - # Convert - $tga_2_dds $i -o $dest -m -r$reduce_bitmap_factor 2>> log.log - fi - - # Idle - ../../idle.bat -done - - -# Bin -hls_bank_maker='hls_bank_maker.exe' - -# build the HLSBank (if hlsInfo present, and if build wanted) -hls_bank_file_name=`cat ../../cfg/config.cfg | grep "hls_bank_file_name" | sed -e 's/hls_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` -if test "$hls_bank_file_name" ; then - rm $hls_bank_file_name - $hls_bank_maker hlsinfo $hls_bank_file_name -fi - - -# Put old panoply in cache - -echo Remove the panoply cache -rm -r cache 2>> log.log - -echo Rename panoply as cache -mv panoply cache 2>> log.log - -echo Move hlsinfo into cache -cp -u -p -R hlsinfo/. cache 2>> log.log - -echo Remove the hlsinfo -rm -r hlsinfo 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# *** Build map files (.tga / .dds) + +# Bin +tga_2_dds='tga2dds.exe' + +# Log error +echo ------- > log.log +echo --- Build map >> log.log +echo ------- >> log.log +echo ------- +echo --- Build map +echo ------- +date >> log.log +date + + +#*** Build panoply files (.tga / .dds), and copy the result in the tga directory + +# Copy panoply containt into cache if the process as been stopped before the end of build. +echo Copy panoply into cache +cp -u -p -R panoply/. cache 2>> log.log +echo Remove panoply directory +rm -r panoply 2>> log.log +echo Copy hlsinfo into cache +cp -u -p -R hlsinfo/. cache 2>> log.log +echo Remove hlsinfo directory +rm -r hlsinfo 2>> log.log + +mkdir panoply +mkdir hlsinfo + +# Bin +panoply_maker='panoply_maker.exe' + +# Log error +echo ------- > log.log +echo --- Build panoply >> log.log +echo ------- >> log.log +echo ------- +echo --- Build panoply +echo ------- +date >> log.log +date + +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Reduce bitmap size factor +reduce_bitmap_factor=`cat ../../cfg/config.cfg | grep "reduce_bitmap_factor" | sed -e 's/reduce_bitmap_factor//' | sed -e 's/ //g' | sed -e 's/=//g'` + +panoply_file_list=`cat ../../cfg/config.cfg | grep "panoply_file_list" | sed -e 's/panoply_file_list//' | sed -e 's/ //g' | sed -e 's/=//g'` +if test "$panoply_file_list" ; then + rm $panoply_file_list + panoply_config_file=`cat ../../cfg/directories.cfg | grep "panoply_config_file" | sed -e 's/panoply_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` + for psource in $panoply_config_file ; do + cp $database_directory/$psource current_panoply.cfg + echo "output_path=\"panoply\";" >> current_panoply.cfg + echo "cache_path=\"cache\";" >> current_panoply.cfg + panoply_maker.exe current_panoply.cfg + + # Idle + ../../idle.bat + done + ls panoply >> $panoply_file_list +fi + +# For each directoy +for i in tga/*.[tT][gG][aA] ; do + + # Destination file + dest=`echo $i | sed -e 's/[tT][gG][aA]/dds/' | sed -e 's/\.[tT][gG][aA]/.dds/g'` + dds=`echo $i | sed -e 's/\.[tT][gG][aA]/.dds/g'` + + # Convert the lightmap in 16 bits mode + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + # Copy the dds file + if (test -f $dds) + then + cp $dds $dest + fi + + # Convert + $tga_2_dds $i -o $dest -m -r$reduce_bitmap_factor 2>> log.log + fi + + # Idle + ../../idle.bat +done + +for i in panoply/*.[tT][gG][aA] ; do + + # Destination file + dest=`echo $i | sed -e 's%panoply/%dds/%g' | sed -e 's/[tT][gG][aA]/dds/g'` + dds=`echo $i | sed -e 's/\.[tT][gG][aA]/.dds/g'` + + # Convert the lightmap in 16 bits mode + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + # Copy the dds file + if (test -f $dds) + then + cp $dds $dest + fi + + # Convert + $tga_2_dds $i -o $dest -m -r$reduce_bitmap_factor 2>> log.log + fi + + # Idle + ../../idle.bat +done + + +# Bin +hls_bank_maker='hls_bank_maker.exe' + +# build the HLSBank (if hlsInfo present, and if build wanted) +hls_bank_file_name=`cat ../../cfg/config.cfg | grep "hls_bank_file_name" | sed -e 's/hls_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` +if test "$hls_bank_file_name" ; then + rm $hls_bank_file_name + $hls_bank_maker hlsinfo $hls_bank_file_name +fi + + +# Put old panoply in cache + +echo Remove the panoply cache +rm -r cache 2>> log.log + +echo Rename panoply as cache +mv panoply cache 2>> log.log + +echo Move hlsinfo into cache +cp -u -p -R hlsinfo/. cache 2>> log.log + +echo Remove the hlsinfo +rm -r hlsinfo 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/map/sh/export.sh b/nel/tools/3d/build_gamedata/processes/map/sh/export.sh index e66432f11..116cbb083 100644 --- a/nel/tools/3d/build_gamedata/processes/map/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/map/sh/export.sh @@ -1,57 +1,57 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export maps files (.tga / *.[dD][dD][sS]) from the database - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the maps directories -map_source_directories=`cat ../../cfg/directories.cfg | grep "map_source_directory" | sed -e 's/map_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` -map_uncompressed_source_directories=`cat ../../cfg/directories.cfg | grep "map_uncompressed_source_directory" | sed -e 's/map_uncompressed_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - - -# Log error -echo ------- > log.log -echo --- Export map >> log.log -echo ------- >> log.log -echo ------- -echo --- Export map -echo ------- -date >> log.log -date - -# For each directoy - -for i in $map_source_directories; do - for j in $database_directory/$i/*.[tT][gG][aA]; do - if ( test -f $j ) - then - # Get the dds version - dds=`echo $j | sed -e 's&.tga&.dds&g'` - - # Copy the dds and the tga - cp -u -p $j tga 2>> log.log - if ( test -f $dds ) - then - cp -u -p $dds tga 2>> log.log - fi - fi - done - # Idle - ../../idle.bat -done - -for i in $map_uncompressed_source_directories; do - for j in $database_directory/$i/*.[tT][gG][aA]; do - if ( test -f $j ) - then - # Copy the dds and the tga - cp -u -p $j tga_uncompressed 2>> log.log - fi - done - # Idle - ../../idle.bat -done - - +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export maps files (.tga / *.[dD][dD][sS]) from the database + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the maps directories +map_source_directories=`cat ../../cfg/directories.cfg | grep "map_source_directory" | sed -e 's/map_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` +map_uncompressed_source_directories=`cat ../../cfg/directories.cfg | grep "map_uncompressed_source_directory" | sed -e 's/map_uncompressed_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + + +# Log error +echo ------- > log.log +echo --- Export map >> log.log +echo ------- >> log.log +echo ------- +echo --- Export map +echo ------- +date >> log.log +date + +# For each directoy + +for i in $map_source_directories; do + for j in $database_directory/$i/*.[tT][gG][aA]; do + if ( test -f $j ) + then + # Get the dds version + dds=`echo $j | sed -e 's&.tga&.dds&g'` + + # Copy the dds and the tga + cp -u -p $j tga 2>> log.log + if ( test -f $dds ) + then + cp -u -p $dds tga 2>> log.log + fi + fi + done + # Idle + ../../idle.bat +done + +for i in $map_uncompressed_source_directories; do + for j in $database_directory/$i/*.[tT][gG][aA]; do + if ( test -f $j ) + then + # Copy the dds and the tga + cp -u -p $j tga_uncompressed 2>> log.log + fi + done + # Idle + ../../idle.bat +done + + diff --git a/nel/tools/3d/build_gamedata/processes/map/sh/install.sh b/nel/tools/3d/build_gamedata/processes/map/sh/install.sh index 434563d2f..51bbc97e8 100644 --- a/nel/tools/3d/build_gamedata/processes/map/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/map/sh/install.sh @@ -1,55 +1,55 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install maps in the client data - -# Get the skel install directory -bitmap_install_directory=`cat ../../cfg/directories.cfg | grep "bitmap_install_directory" | sed -e 's/bitmap_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install maps >> log.log -echo ------- >> log.log -echo ------- -echo --- Install maps -echo ------- -date >> log.log -date - -cp -u -p -R dds/. $client_directory/$bitmap_install_directory 2>> log.log -cp -u -p -R tga_uncompressed/. $client_directory/$bitmap_install_directory 2>> log.log - -panoply_file_list=`cat ../../cfg/config.cfg | grep "panoply_file_list" | sed -e 's/panoply_file_list//' | sed -e 's/ //g' | sed -e 's/=//g'` -if test "$panoply_file_list" ; then - cp -u -p $panoply_file_list $client_directory/$bitmap_install_directory 2>> log.log - panoply_config_file=`cat ../../cfg/directories.cfg | grep "panoply_config_file" | sed -e 's/panoply_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` - for psource in $panoply_config_file ; do - cp $database_directory/$psource $client_directory/$bitmap_install_directory/panoply.cfg - done - ls panoply >> $panoply_file_list -fi - - -# Install hlsbank in the client data, in the "maps/" directory - -# Log error -echo --- Install hlsbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Install hlsbank -echo ------- -date >> log.log -date - -# build the HLSBank (if hlsInfo present, and if build wanted) -hls_bank_file_name=`cat ../../cfg/config.cfg | grep "hls_bank_file_name" | sed -e 's/hls_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` -if test "$hls_bank_file_name" ; then - cp -u -p -R $hls_bank_file_name $client_directory/$bitmap_install_directory 2>> log.log -fi - +#!/bin/bash +rm log.log 2> /dev/null + +# Install maps in the client data + +# Get the skel install directory +bitmap_install_directory=`cat ../../cfg/directories.cfg | grep "bitmap_install_directory" | sed -e 's/bitmap_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install maps >> log.log +echo ------- >> log.log +echo ------- +echo --- Install maps +echo ------- +date >> log.log +date + +cp -u -p -R dds/. $client_directory/$bitmap_install_directory 2>> log.log +cp -u -p -R tga_uncompressed/. $client_directory/$bitmap_install_directory 2>> log.log + +panoply_file_list=`cat ../../cfg/config.cfg | grep "panoply_file_list" | sed -e 's/panoply_file_list//' | sed -e 's/ //g' | sed -e 's/=//g'` +if test "$panoply_file_list" ; then + cp -u -p $panoply_file_list $client_directory/$bitmap_install_directory 2>> log.log + panoply_config_file=`cat ../../cfg/directories.cfg | grep "panoply_config_file" | sed -e 's/panoply_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` + for psource in $panoply_config_file ; do + cp $database_directory/$psource $client_directory/$bitmap_install_directory/panoply.cfg + done + ls panoply >> $panoply_file_list +fi + + +# Install hlsbank in the client data, in the "maps/" directory + +# Log error +echo --- Install hlsbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Install hlsbank +echo ------- +date >> log.log +date + +# build the HLSBank (if hlsInfo present, and if build wanted) +hls_bank_file_name=`cat ../../cfg/config.cfg | grep "hls_bank_file_name" | sed -e 's/hls_bank_file_name//' | sed -e 's/ //g' | sed -e 's/=//g'` +if test "$hls_bank_file_name" ; then + cp -u -p -R $hls_bank_file_name $client_directory/$bitmap_install_directory 2>> log.log +fi + diff --git a/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/export.sh b/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/export.sh index e4bdd3c3b..f234588a4 100644 --- a/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/export.sh @@ -1,59 +1,59 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export pacs_prim files (.pacs_prim) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "pacs_prim_export_timeout" | sed -e 's/pacs_prim_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the collision directories -pacs_prim_source_directories=`cat ../../cfg/directories.cfg | grep "pacs_prim_source_directories" | sed -e 's/pacs_prim_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export pacs_prim for pacs_prim >> log.log -echo ------- >> log.log -echo ------- -echo --- Export pacs_prim for pacs_prim -echo ------- -date >> log.log -date - -# For each directoy - -for i in $pacs_prim_source_directories ; do - # Copy the script - cat maxscript/pacs_prim_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/pacs_prim/log.log&g" | sed -e "s&pacs_prim_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/pacs_prim/pacs_prim&g" > $max_directory/scripts/pacs_prim_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - -rm landscape_col_prim_pacs_list.txt +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export pacs_prim files (.pacs_prim) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "pacs_prim_export_timeout" | sed -e 's/pacs_prim_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the collision directories +pacs_prim_source_directories=`cat ../../cfg/directories.cfg | grep "pacs_prim_source_directories" | sed -e 's/pacs_prim_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export pacs_prim for pacs_prim >> log.log +echo ------- >> log.log +echo ------- +echo --- Export pacs_prim for pacs_prim +echo ------- +date >> log.log +date + +# For each directoy + +for i in $pacs_prim_source_directories ; do + # Copy the script + cat maxscript/pacs_prim_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/pacs_prim/log.log&g" | sed -e "s&pacs_prim_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/pacs_prim/pacs_prim&g" > $max_directory/scripts/pacs_prim_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript pacs_prim_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + +rm landscape_col_prim_pacs_list.txt diff --git a/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/install.sh b/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/install.sh index 5aee55fb9..bcfea1aff 100644 --- a/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/pacs_prim/sh/install.sh @@ -1,30 +1,30 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the zonels in the client data - -# Get the zone install directory -pacs_primitive_install_directory=`cat ../../cfg/directories.cfg | grep "pacs_primitive_install_directory" | sed -e 's/pacs_primitive_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Test if there is a need for the prim pacs directory -want_landscape_col_prim_pacs_list=`cat ../../cfg/config.cfg | grep "want_landscape_col_prim_pacs_list"` - -# Log error -echo ------- > log.log -echo --- Install zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Install zone -echo ------- -date >> log.log -date - -cp -u -p -R pacs_prim/. $client_directory/$pacs_primitive_install_directory 2>> log.log - -if test "$want_landscape_col_prim_pacs_list" ; then - ls pacs_prim | grep ".pacs_prim" >> $client_directory/landscape_col_prim_pacs_list.txt -fi - +#!/bin/bash +rm log.log 2> /dev/null + +# Install the zonels in the client data + +# Get the zone install directory +pacs_primitive_install_directory=`cat ../../cfg/directories.cfg | grep "pacs_primitive_install_directory" | sed -e 's/pacs_primitive_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Test if there is a need for the prim pacs directory +want_landscape_col_prim_pacs_list=`cat ../../cfg/config.cfg | grep "want_landscape_col_prim_pacs_list"` + +# Log error +echo ------- > log.log +echo --- Install zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Install zone +echo ------- +date >> log.log +date + +cp -u -p -R pacs_prim/. $client_directory/$pacs_primitive_install_directory 2>> log.log + +if test "$want_landscape_col_prim_pacs_list" ; then + ls pacs_prim | grep ".pacs_prim" >> $client_directory/landscape_col_prim_pacs_list.txt +fi + diff --git a/nel/tools/3d/build_gamedata/processes/ps/sh/export.sh b/nel/tools/3d/build_gamedata/processes/ps/sh/export.sh index c1699a625..94d490c2e 100644 --- a/nel/tools/3d/build_gamedata/processes/ps/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/ps/sh/export.sh @@ -1,31 +1,31 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export particle system file (.ps) - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the ps directories -ps_source_directories=`cat ../../cfg/directories.cfg | grep "ps_source_directory" | sed -e 's/ps_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export ps >> log.log -echo ------- >> log.log -echo ------- -echo --- Export ps -echo ------- -date >> log.log -date - -# For each ps directory -for i in $ps_source_directories ; do - # Copy - cp -u -p $database_directory/$i/*.[pP][sS] ps 2>> log.log - cp -u -p $database_directory/$i/*.[sS][hH][aA][pP][eE] ps 2>> log.log - cp -u -p $database_directory/$i/*.[pP][rR][iI][mM][iI][tT][iI][vV][eE] ps 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export particle system file (.ps) + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the ps directories +ps_source_directories=`cat ../../cfg/directories.cfg | grep "ps_source_directory" | sed -e 's/ps_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export ps >> log.log +echo ------- >> log.log +echo ------- +echo --- Export ps +echo ------- +date >> log.log +date + +# For each ps directory +for i in $ps_source_directories ; do + # Copy + cp -u -p $database_directory/$i/*.[pP][sS] ps 2>> log.log + cp -u -p $database_directory/$i/*.[sS][hH][aA][pP][eE] ps 2>> log.log + cp -u -p $database_directory/$i/*.[pP][rR][iI][mM][iI][tT][iI][vV][eE] ps 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/ps/sh/install.sh b/nel/tools/3d/build_gamedata/processes/ps/sh/install.sh index 9ab0cfad0..171b7c72d 100644 --- a/nel/tools/3d/build_gamedata/processes/ps/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/ps/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the particule system in the client data - -# Get the ps install directory -ps_install_directory=`cat ../../cfg/directories.cfg | grep "ps_install_directory" | sed -e 's/ps_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install ps >> log.log -echo ------- >> log.log -echo ------- -echo --- Install ps -echo ------- -date >> log.log -date - -cp -u -p -R ps/. $client_directory/$ps_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the particule system in the client data + +# Get the ps install directory +ps_install_directory=`cat ../../cfg/directories.cfg | grep "ps_install_directory" | sed -e 's/ps_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install ps >> log.log +echo ------- >> log.log +echo ------- +echo --- Install ps +echo ------- +date >> log.log +date + +cp -u -p -R ps/. $client_directory/$ps_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/rbank/sh/build.sh b/nel/tools/3d/build_gamedata/processes/rbank/sh/build.sh index 1ba877899..26abaa796 100644 --- a/nel/tools/3d/build_gamedata/processes/rbank/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/rbank/sh/build.sh @@ -1,358 +1,358 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build zone - -build_rbank='build_rbank.exe' -build_indoor_rbank='build_indoor_rbank.exe' -build_ig_boxes='build_ig_boxes.exe' -ai_build_wmap='ai_build_wmap_r.exe' -get_neighbors='get_neighbors.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -tessel_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_tessel_timeout" | sed -e 's/rbank_build_tessel_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -smooth_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_smooth_timeout" | sed -e 's/rbank_build_smooth_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -proclocal_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_proclocal_timeout" | sed -e 's/rbank_build_proclocal_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -procglobal_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_procglobal_timeout" | sed -e 's/rbank_build_procglobal_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -indoor_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_indoor_timeout" | sed -e 's/rbank_build_indoor_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -build_wmap_timeout=`cat ../../cfg/config.cfg | grep "build_wmap_timeout" | sed -e 's/build_wmap_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the quality option to choose the goor properties.cfg file -quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` - -# **** Copy ig and shapes - -# Log error -echo >> log.log -echo ------- > log.log -echo --- Generate config script >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Generate config script -echo ------- -echo -date >> log.log -date - -# Get arguments -rbank_bank_name=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` -rbank_reduce_surfaces=`cat ../../cfg/config.cfg | grep "rbank_reduce_surfaces" | sed -e 's/rbank_reduce_surfaces//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_smooth_borders=`cat ../../cfg/config.cfg | grep "rbank_smooth_borders" | sed -e 's/rbank_smooth_borders//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_compute_elevation=`cat ../../cfg/config.cfg | grep "rbank_compute_elevation" | sed -e 's/rbank_compute_elevation//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_compute_levels=`cat ../../cfg/config.cfg | grep "rbank_compute_levels" | sed -e 's/rbank_compute_levels//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_link_elements=`cat ../../cfg/config.cfg | grep "rbank_link_elements" | sed -e 's/rbank_link_elements//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_cut_edges=`cat ../../cfg/config.cfg | grep "rbank_cut_edges" | sed -e 's/rbank_cut_edges//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_use_zone_square=`cat ../../cfg/config.cfg | grep "rbank_use_zone_square" | sed -e 's/rbank_use_zone_square//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_zone_ul=`cat ../../cfg/config.cfg | grep "rbank_zone_ul" | sed -e 's/rbank_zone_ul//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_zone_dr=`cat ../../cfg/config.cfg | grep "rbank_zone_dr" | sed -e 's/rbank_zone_dr//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_rbank_name=`cat ../../cfg/config.cfg | grep "rbank_rbank_name" | sed -e 's/rbank_rbank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_ig_pathes=`cat ../../cfg/config.cfg | grep "rbank_ig_path" | sed -e 's/rbank_ig_path//' | sed -e 's/ //g' | sed -e 's/=//g'` -rbank_shape_pathes=`cat ../../cfg/config.cfg | grep "rbank_shape_path" | sed -e 's/rbank_shape_path//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Global options -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Build the bbox file >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Build the bbox file -echo ------- -echo -date >> log.log -date - -# ***** Build the bbox file - -# Remove the config file -rm build_ig_boxes.cfg - -# List ig pathes -echo Pathes = \{ >> build_ig_boxes.cfg -for i in $rbank_ig_pathes ; do - echo \"$i\"\, >> build_ig_boxes.cfg -done -for i in $rbank_shape_pathes ; do - echo \"$i\"\, >> build_ig_boxes.cfg -done -echo \}\; >> build_ig_boxes.cfg - -# List igs -echo IGs = \{ >> build_ig_boxes.cfg -for i in $rbank_ig_pathes ; do - cd $i - list_ig=`ls -1 *.[iI][gG]` - cd $build_gamedata_directory"/processes/rbank" - for j in $list_ig ; do - n=`echo $j | sed -e 's/.ig//'` - echo \"$n\"\, >> build_ig_boxes.cfg - done - - # Idle - ../../idle.bat -done -echo \}\; >> build_ig_boxes.cfg -echo Output = \"bbox/temp.bbox\"\; >> build_ig_boxes.cfg - -# -- NOT NEEDED ANYMORE -$build_ig_boxes - -# ***** Build the rbank, gr files - -# Copy the good template file -if ( test "$quality_flag" ) -then - # We are in BEST mode - `cat cfg/template_final.cfg | sed -e "s&rbank_bank_name&$rbank_bank_name&g" | sed -e "s&rbank_reduce_surfaces&$rbank_reduce_surfaces&g" | sed -e "s&rbank_smooth_borders&$rbank_smooth_borders&g" | sed -e "s&rbank_compute_elevation&$rbank_compute_elevation&g" | sed -e "s&rbank_compute_levels&$rbank_compute_levels&g" | sed -e "s&rbank_link_elements&$rbank_link_elements&g" | sed -e "s&rbank_cut_edges&$rbank_cut_edges&g" | sed -e "s&rbank_use_zone_square&$rbank_use_zone_square&g" | sed -e "s&rbank_zone_ul&$rbank_zone_ul&g" | sed -e "s&rbank_zone_dr&$rbank_zone_dr&g" > build_rbank.cfg` -else - # We are in DRAFT mode - `cat cfg/template_draft.cfg | sed -e "s&rbank_bank_name&$rbank_bank_name&g" | sed -e "s&rbank_reduce_surfaces&$rbank_reduce_surfaces&g" | sed -e "s&rbank_smooth_borders&$rbank_smooth_borders&g" | sed -e "s&rbank_compute_elevation&$rbank_compute_elevation&g" | sed -e "s&rbank_compute_levels&$rbank_compute_levels&g" | sed -e "s&rbank_link_elements&$rbank_link_elements&g" | sed -e "s&rbank_cut_edges&$rbank_cut_edges&g" | sed -e "s&rbank_use_zone_square&$rbank_use_zone_square&g" | sed -e "s&rbank_zone_ul&$rbank_zone_ul&g" | sed -e "s&rbank_zone_dr&$rbank_zone_dr&g" > build_rbank.cfg` -fi - -# List the zones to add -cd ../zone/zone_welded -list_zone=`ls -1 *.[zZ][oO][nN][eE][wW]` -cd ../../rbank - -# Make a zone list -for i in $list_zone ; do - echo \"$i\", >> build_rbank.cfg -done - -# Close the file -echo "};" >> build_rbank.cfg -echo " " >> build_rbank.cfg - -# List ig pathes -echo Pathes = \{ >> build_rbank.cfg -for i in $rbank_ig_pathes ; do - echo \"$i\"\, >> build_rbank.cfg -done -for i in $rbank_shape_pathes ; do - echo \"$i\"\, >> build_rbank.cfg -done -echo \}\; >> build_rbank.cfg - -echo " " >> build_rbank.cfg - - -# Log error -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Check pacs primitives consistency >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Check pacs primitives consistency -echo ------- -echo -date >> log.log -date - -# ******* PASS 1 Generate smooth lr - -# For each ../zone/zone_welded/*.[zZ][oO][nN][eE][wW] files, checks if the associated scratch/tesselation/*.[tT][eE][sS][sS][eE][lL] file -# are up to date with the .zonew and the 8 neighbor .zonew file. If note, tesselate it. - -$exec_timeout $tessel_timeout $build_rbank -C -p -g - -# Log error -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Generate lr >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Generate lr -echo ------- -echo -date >> log.log -date - -for i in $list_zone ; do - - # Get destination file - zone=`echo $i | sed -e 's/.zonew//'` - - # Lr final - lr1=`echo "smooth/"$zone".lr"` - - # Get the 9 zones list - near_zone=`$get_neighbors $zone` - - # Zone to build - zone_to_build=`echo ""` - - # For each zone near - if ( ! test -e $lr1 ) - then - zone_to_build=`echo "../zone/zone_welded/"$i` - else - for j in $near_zone ; do - if ( test "../zone/zone_welded/"$j.zonew -nt $lr1 ) - then - zone_to_build=`echo "../zone/zone_welded/"$i` - fi - done - fi - - # Build it only if the file exist - if ( test "$zone_to_build" ) - then - # Build lr - $exec_timeout $tessel_timeout $build_rbank -c -P -g $i - - echo - echo >> log.log - else - echo SKIPPED $dest - echo - echo SKIPPED $lr1 >> log.log - echo >> log.log - fi - - - # Idle - ../../idle.bat -done - - - -# Log error -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Procglobal >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Procglobal -echo ------- -echo -date >> log.log -date - -# Procglobal -$exec_timeout $procglobal_timeout $build_rbank -c -p -G - - - - - -# ***** Build the cfg for interiors - -rm build_indoor_rbank.cfg -echo MeshPath = \"cmb/\"\; >> build_indoor_rbank.cfg -echo Meshes = { >> build_indoor_rbank.cfg - -# List the cmb to merge -cd cmb -list_cmb=`ls -1 *.[cC][mM][bB]` -cd .. -for i in $list_cmb ; do - n=`echo $i | sed -e 's/.cmb//'` - echo \"$n\", >> build_indoor_rbank.cfg - - # Idle - ../../idle.bat -done - -echo "};" >> build_indoor_rbank.cfg -echo OutputPath = \""retrievers/"\"\; >> build_indoor_rbank.cfg -echo OutputPrefix = "unused"\; >> build_indoor_rbank.cfg -echo Merge = 1\; >> build_indoor_rbank.cfg -echo MergePath = \""smooth/"\"\; >> build_indoor_rbank.cfg -echo MergeInputPrefix = \"temp\"\; >> build_indoor_rbank.cfg -echo MergeOutputPrefix = \"tempMerged\"\; >> build_indoor_rbank.cfg -echo AddToRetriever = \"1\"\; >> build_indoor_rbank.cfg - -# Log error -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Merge cmb in rbank >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Merge cmb in rbank -echo ------- -echo -date >> log.log -date - -$exec_timeout $indoor_timeout $build_indoor_rbank - - - - - - -echo >> log.log -echo ------- >> log.log -echo --- Build RBank : Copy gr, rbank and lr >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Build RBank : Copy gr, rbank and lr -echo ------- -echo -date >> log.log -date - - - -# Copy the files -mv "retrievers"/tempMerged.rbank output/$rbank_rbank_name".rbank" 2>> log.log -mv "retrievers"/tempMerged.gr output/$rbank_rbank_name".gr" 2>> log.log -for i in "retrievers"/tempMerged_*.lr ; do - finalname=`echo $i | sed -e "s/tempMerged/$rbank_rbank_name/" | sed -e 's/retrievers/output/'` - mv $i $finalname -done - - -# -# removed from pacs process, ai_build_wmap is built later, independently -# - -# Check ai_build_wmap exist -#if ( test -f $ai_build_wmap ) -#then -# # setup config file for ai_build_wmap -# rm ./ai_build_wmap.cfg -# cp cfg/ai_build_wmap.cfg ./ai_build_wmap.cfg -# -# # generate wmap -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsCrunch $rbank_rbank_name" -# -# # generate sizes -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildGabarit $rbank_rbank_name" -# -# # generate cwmaps for each size -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_0" -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_1" -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_2" -# -# # generate bitmap for each size -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_0" -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_1" -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_2" -# -# # clear height maps for size 1 and 2 -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsClearHeightmap ${rbank_rbank_name}_1" -# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsClearHeightmap ${rbank_rbank_name}_2" -# -# rm output/$rbank_rbank_name.wmap -# rm output/${rbank_rbank_name}_0.wmap -# rm output/${rbank_rbank_name}_1.wmap -# rm output/${rbank_rbank_name}_2.wmap -#fi +#!/bin/bash +rm log.log 2> /dev/null + +# Build zone + +build_rbank='build_rbank.exe' +build_indoor_rbank='build_indoor_rbank.exe' +build_ig_boxes='build_ig_boxes.exe' +ai_build_wmap='ai_build_wmap_r.exe' +get_neighbors='get_neighbors.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +tessel_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_tessel_timeout" | sed -e 's/rbank_build_tessel_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +smooth_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_smooth_timeout" | sed -e 's/rbank_build_smooth_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +proclocal_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_proclocal_timeout" | sed -e 's/rbank_build_proclocal_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +procglobal_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_procglobal_timeout" | sed -e 's/rbank_build_procglobal_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +indoor_timeout=`cat ../../cfg/config.cfg | grep "rbank_build_indoor_timeout" | sed -e 's/rbank_build_indoor_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +build_wmap_timeout=`cat ../../cfg/config.cfg | grep "build_wmap_timeout" | sed -e 's/build_wmap_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the quality option to choose the goor properties.cfg file +quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` + +# **** Copy ig and shapes + +# Log error +echo >> log.log +echo ------- > log.log +echo --- Generate config script >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Generate config script +echo ------- +echo +date >> log.log +date + +# Get arguments +rbank_bank_name=`cat ../../cfg/properties.cfg | grep "bank_name" | sed -e 's/bank_name//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/"//g' | sed -e 's/;//g'` +rbank_reduce_surfaces=`cat ../../cfg/config.cfg | grep "rbank_reduce_surfaces" | sed -e 's/rbank_reduce_surfaces//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_smooth_borders=`cat ../../cfg/config.cfg | grep "rbank_smooth_borders" | sed -e 's/rbank_smooth_borders//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_compute_elevation=`cat ../../cfg/config.cfg | grep "rbank_compute_elevation" | sed -e 's/rbank_compute_elevation//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_compute_levels=`cat ../../cfg/config.cfg | grep "rbank_compute_levels" | sed -e 's/rbank_compute_levels//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_link_elements=`cat ../../cfg/config.cfg | grep "rbank_link_elements" | sed -e 's/rbank_link_elements//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_cut_edges=`cat ../../cfg/config.cfg | grep "rbank_cut_edges" | sed -e 's/rbank_cut_edges//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_use_zone_square=`cat ../../cfg/config.cfg | grep "rbank_use_zone_square" | sed -e 's/rbank_use_zone_square//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_zone_ul=`cat ../../cfg/config.cfg | grep "rbank_zone_ul" | sed -e 's/rbank_zone_ul//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_zone_dr=`cat ../../cfg/config.cfg | grep "rbank_zone_dr" | sed -e 's/rbank_zone_dr//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_rbank_name=`cat ../../cfg/config.cfg | grep "rbank_rbank_name" | sed -e 's/rbank_rbank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_ig_pathes=`cat ../../cfg/config.cfg | grep "rbank_ig_path" | sed -e 's/rbank_ig_path//' | sed -e 's/ //g' | sed -e 's/=//g'` +rbank_shape_pathes=`cat ../../cfg/config.cfg | grep "rbank_shape_path" | sed -e 's/rbank_shape_path//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Global options +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Build the bbox file >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Build the bbox file +echo ------- +echo +date >> log.log +date + +# ***** Build the bbox file + +# Remove the config file +rm build_ig_boxes.cfg + +# List ig pathes +echo Pathes = \{ >> build_ig_boxes.cfg +for i in $rbank_ig_pathes ; do + echo \"$i\"\, >> build_ig_boxes.cfg +done +for i in $rbank_shape_pathes ; do + echo \"$i\"\, >> build_ig_boxes.cfg +done +echo \}\; >> build_ig_boxes.cfg + +# List igs +echo IGs = \{ >> build_ig_boxes.cfg +for i in $rbank_ig_pathes ; do + cd $i + list_ig=`ls -1 *.[iI][gG]` + cd $build_gamedata_directory"/processes/rbank" + for j in $list_ig ; do + n=`echo $j | sed -e 's/.ig//'` + echo \"$n\"\, >> build_ig_boxes.cfg + done + + # Idle + ../../idle.bat +done +echo \}\; >> build_ig_boxes.cfg +echo Output = \"bbox/temp.bbox\"\; >> build_ig_boxes.cfg + +# -- NOT NEEDED ANYMORE +$build_ig_boxes + +# ***** Build the rbank, gr files + +# Copy the good template file +if ( test "$quality_flag" ) +then + # We are in BEST mode + `cat cfg/template_final.cfg | sed -e "s&rbank_bank_name&$rbank_bank_name&g" | sed -e "s&rbank_reduce_surfaces&$rbank_reduce_surfaces&g" | sed -e "s&rbank_smooth_borders&$rbank_smooth_borders&g" | sed -e "s&rbank_compute_elevation&$rbank_compute_elevation&g" | sed -e "s&rbank_compute_levels&$rbank_compute_levels&g" | sed -e "s&rbank_link_elements&$rbank_link_elements&g" | sed -e "s&rbank_cut_edges&$rbank_cut_edges&g" | sed -e "s&rbank_use_zone_square&$rbank_use_zone_square&g" | sed -e "s&rbank_zone_ul&$rbank_zone_ul&g" | sed -e "s&rbank_zone_dr&$rbank_zone_dr&g" > build_rbank.cfg` +else + # We are in DRAFT mode + `cat cfg/template_draft.cfg | sed -e "s&rbank_bank_name&$rbank_bank_name&g" | sed -e "s&rbank_reduce_surfaces&$rbank_reduce_surfaces&g" | sed -e "s&rbank_smooth_borders&$rbank_smooth_borders&g" | sed -e "s&rbank_compute_elevation&$rbank_compute_elevation&g" | sed -e "s&rbank_compute_levels&$rbank_compute_levels&g" | sed -e "s&rbank_link_elements&$rbank_link_elements&g" | sed -e "s&rbank_cut_edges&$rbank_cut_edges&g" | sed -e "s&rbank_use_zone_square&$rbank_use_zone_square&g" | sed -e "s&rbank_zone_ul&$rbank_zone_ul&g" | sed -e "s&rbank_zone_dr&$rbank_zone_dr&g" > build_rbank.cfg` +fi + +# List the zones to add +cd ../zone/zone_welded +list_zone=`ls -1 *.[zZ][oO][nN][eE][wW]` +cd ../../rbank + +# Make a zone list +for i in $list_zone ; do + echo \"$i\", >> build_rbank.cfg +done + +# Close the file +echo "};" >> build_rbank.cfg +echo " " >> build_rbank.cfg + +# List ig pathes +echo Pathes = \{ >> build_rbank.cfg +for i in $rbank_ig_pathes ; do + echo \"$i\"\, >> build_rbank.cfg +done +for i in $rbank_shape_pathes ; do + echo \"$i\"\, >> build_rbank.cfg +done +echo \}\; >> build_rbank.cfg + +echo " " >> build_rbank.cfg + + +# Log error +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Check pacs primitives consistency >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Check pacs primitives consistency +echo ------- +echo +date >> log.log +date + +# ******* PASS 1 Generate smooth lr + +# For each ../zone/zone_welded/*.[zZ][oO][nN][eE][wW] files, checks if the associated scratch/tesselation/*.[tT][eE][sS][sS][eE][lL] file +# are up to date with the .zonew and the 8 neighbor .zonew file. If note, tesselate it. + +$exec_timeout $tessel_timeout $build_rbank -C -p -g + +# Log error +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Generate lr >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Generate lr +echo ------- +echo +date >> log.log +date + +for i in $list_zone ; do + + # Get destination file + zone=`echo $i | sed -e 's/.zonew//'` + + # Lr final + lr1=`echo "smooth/"$zone".lr"` + + # Get the 9 zones list + near_zone=`$get_neighbors $zone` + + # Zone to build + zone_to_build=`echo ""` + + # For each zone near + if ( ! test -e $lr1 ) + then + zone_to_build=`echo "../zone/zone_welded/"$i` + else + for j in $near_zone ; do + if ( test "../zone/zone_welded/"$j.zonew -nt $lr1 ) + then + zone_to_build=`echo "../zone/zone_welded/"$i` + fi + done + fi + + # Build it only if the file exist + if ( test "$zone_to_build" ) + then + # Build lr + $exec_timeout $tessel_timeout $build_rbank -c -P -g $i + + echo + echo >> log.log + else + echo SKIPPED $dest + echo + echo SKIPPED $lr1 >> log.log + echo >> log.log + fi + + + # Idle + ../../idle.bat +done + + + +# Log error +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Procglobal >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Procglobal +echo ------- +echo +date >> log.log +date + +# Procglobal +$exec_timeout $procglobal_timeout $build_rbank -c -p -G + + + + + +# ***** Build the cfg for interiors + +rm build_indoor_rbank.cfg +echo MeshPath = \"cmb/\"\; >> build_indoor_rbank.cfg +echo Meshes = { >> build_indoor_rbank.cfg + +# List the cmb to merge +cd cmb +list_cmb=`ls -1 *.[cC][mM][bB]` +cd .. +for i in $list_cmb ; do + n=`echo $i | sed -e 's/.cmb//'` + echo \"$n\", >> build_indoor_rbank.cfg + + # Idle + ../../idle.bat +done + +echo "};" >> build_indoor_rbank.cfg +echo OutputPath = \""retrievers/"\"\; >> build_indoor_rbank.cfg +echo OutputPrefix = "unused"\; >> build_indoor_rbank.cfg +echo Merge = 1\; >> build_indoor_rbank.cfg +echo MergePath = \""smooth/"\"\; >> build_indoor_rbank.cfg +echo MergeInputPrefix = \"temp\"\; >> build_indoor_rbank.cfg +echo MergeOutputPrefix = \"tempMerged\"\; >> build_indoor_rbank.cfg +echo AddToRetriever = \"1\"\; >> build_indoor_rbank.cfg + +# Log error +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Merge cmb in rbank >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Merge cmb in rbank +echo ------- +echo +date >> log.log +date + +$exec_timeout $indoor_timeout $build_indoor_rbank + + + + + + +echo >> log.log +echo ------- >> log.log +echo --- Build RBank : Copy gr, rbank and lr >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Build RBank : Copy gr, rbank and lr +echo ------- +echo +date >> log.log +date + + + +# Copy the files +mv "retrievers"/tempMerged.rbank output/$rbank_rbank_name".rbank" 2>> log.log +mv "retrievers"/tempMerged.gr output/$rbank_rbank_name".gr" 2>> log.log +for i in "retrievers"/tempMerged_*.lr ; do + finalname=`echo $i | sed -e "s/tempMerged/$rbank_rbank_name/" | sed -e 's/retrievers/output/'` + mv $i $finalname +done + + +# +# removed from pacs process, ai_build_wmap is built later, independently +# + +# Check ai_build_wmap exist +#if ( test -f $ai_build_wmap ) +#then +# # setup config file for ai_build_wmap +# rm ./ai_build_wmap.cfg +# cp cfg/ai_build_wmap.cfg ./ai_build_wmap.cfg +# +# # generate wmap +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsCrunch $rbank_rbank_name" +# +# # generate sizes +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildGabarit $rbank_rbank_name" +# +# # generate cwmaps for each size +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_0" +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_1" +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildWmap ${rbank_rbank_name}_2" +# +# # generate bitmap for each size +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_0" +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_1" +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsBuildBitmap ${rbank_rbank_name}_2" +# +# # clear height maps for size 1 and 2 +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsClearHeightmap ${rbank_rbank_name}_1" +# $exec_timeout $build_wmap_timeout $ai_build_wmap "pacsClearHeightmap ${rbank_rbank_name}_2" +# +# rm output/$rbank_rbank_name.wmap +# rm output/${rbank_rbank_name}_0.wmap +# rm output/${rbank_rbank_name}_1.wmap +# rm output/${rbank_rbank_name}_2.wmap +#fi diff --git a/nel/tools/3d/build_gamedata/processes/rbank/sh/clean.sh b/nel/tools/3d/build_gamedata/processes/rbank/sh/clean.sh index 82e48430c..7e4189aab 100644 --- a/nel/tools/3d/build_gamedata/processes/rbank/sh/clean.sh +++ b/nel/tools/3d/build_gamedata/processes/rbank/sh/clean.sh @@ -1,31 +1,31 @@ -#!/bin/bash -rm log.log 2> /dev/null - - -# Log error -echo >> log.log -echo ------- > log.log -echo --- Clean rbank >> log.log -echo ------- >> log.log -echo >> log.log -echo -echo ------- -echo --- Clean rbank -echo ------- -echo -date >> log.log -date - -# Get arguments -rbank_rbank_name=`cat ../../cfg/config.cfg | grep "rbank_rbank_name" | sed -e 's/rbank_rbank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Delete temp files -rm tesselation/*.[tT][eE][sS][sS][eE][lL] -rm smooth/*.[lL][rR] -rm smooth/*.[oO][cC][hH][aA][iI][nN] -rm smooth/*.[gG][rR] -rm smooth/*.[rR][bB][aA][nN][kK] -rm smooth/preproc/*.[lL][rR] -rm retrievers/*.[gG][rR] -rm retrievers/*.[rR][bB][aA][nN][kK] - +#!/bin/bash +rm log.log 2> /dev/null + + +# Log error +echo >> log.log +echo ------- > log.log +echo --- Clean rbank >> log.log +echo ------- >> log.log +echo >> log.log +echo +echo ------- +echo --- Clean rbank +echo ------- +echo +date >> log.log +date + +# Get arguments +rbank_rbank_name=`cat ../../cfg/config.cfg | grep "rbank_rbank_name" | sed -e 's/rbank_rbank_name//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Delete temp files +rm tesselation/*.[tT][eE][sS][sS][eE][lL] +rm smooth/*.[lL][rR] +rm smooth/*.[oO][cC][hH][aA][iI][nN] +rm smooth/*.[gG][rR] +rm smooth/*.[rR][bB][aA][nN][kK] +rm smooth/preproc/*.[lL][rR] +rm retrievers/*.[gG][rR] +rm retrievers/*.[rR][bB][aA][nN][kK] + diff --git a/nel/tools/3d/build_gamedata/processes/rbank/sh/export.sh b/nel/tools/3d/build_gamedata/processes/rbank/sh/export.sh index fed89c044..0afefe687 100644 --- a/nel/tools/3d/build_gamedata/processes/rbank/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/rbank/sh/export.sh @@ -1,57 +1,57 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export cmb files (.cmb) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "cmb_export_timeout" | sed -e 's/cmb_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the collision directories -collision_source_directories=`cat ../../cfg/directories.cfg | grep "cmb_source_directory" | sed -e 's/cmb_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export cmb for rbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Export cmb for rbank -echo ------- -date >> log.log -date - -# For each directoy - -for i in $collision_source_directories ; do - # Copy the script - cat maxscript/rbank_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/rbank/log.log&g" | sed -e "s&collision_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_rbank&$build_gamedata_directory/processes/rbank/cmb&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/rbank/tag&g" > $max_directory/scripts/rbank_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export cmb files (.cmb) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "cmb_export_timeout" | sed -e 's/cmb_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the collision directories +collision_source_directories=`cat ../../cfg/directories.cfg | grep "cmb_source_directory" | sed -e 's/cmb_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export cmb for rbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Export cmb for rbank +echo ------- +date >> log.log +date + +# For each directoy + +for i in $collision_source_directories ; do + # Copy the script + cat maxscript/rbank_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/rbank/log.log&g" | sed -e "s&collision_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_rbank&$build_gamedata_directory/processes/rbank/cmb&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/rbank/tag&g" > $max_directory/scripts/rbank_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript rbank_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/rbank/sh/install.sh b/nel/tools/3d/build_gamedata/processes/rbank/sh/install.sh index 986d65225..b3f832a34 100644 --- a/nel/tools/3d/build_gamedata/processes/rbank/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/rbank/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the zonels in the client data - -# Get the zone install directory -pacs_install_directory=`cat ../../cfg/directories.cfg | grep "pacs_install_directory" | sed -e 's/pacs_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Install zone -echo ------- -date >> log.log -date - -cp -u -p -R output/. $client_directory/$pacs_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the zonels in the client data + +# Get the zone install directory +pacs_install_directory=`cat ../../cfg/directories.cfg | grep "pacs_install_directory" | sed -e 's/pacs_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Install zone +echo ------- +date >> log.log +date + +cp -u -p -R output/. $client_directory/$pacs_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/shape/sh/build.sh b/nel/tools/3d/build_gamedata/processes/shape/sh/build.sh index 8d97cff1f..c1c77984c 100644 --- a/nel/tools/3d/build_gamedata/processes/shape/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/shape/sh/build.sh @@ -1,236 +1,236 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Build shape files (.shape) - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Bin -tga_2_dds='tga2dds.exe' -build_coarse_mesh='build_coarse_mesh.exe' -lightmap_optimizer='lightmap_optimizer.exe' -build_clodtex='build_clodtex.exe' -build_shadow_skin='build_shadow_skin.exe' - -# Log error -echo ------- > log.log -echo --- Build ShadowSkin shape >> log.log -echo ------- >> log.log -echo ------- -echo --- Build ShadowSkin shape -echo ------- -date >> log.log -date - -# build shadow skin? -do_build_shadow_skin=`cat ../../cfg/config.cfg | grep -w "build_shadow_skin" | sed -e 's/build_shadow_skin//' | sed -e 's/ //g' | sed -e 's/=//g'` -build_shadow_skin_ratio=`cat ../../cfg/config.cfg | grep "build_shadow_skin_ratio" | sed -e 's/build_shadow_skin_ratio//' | sed -e 's/ //g' | sed -e 's/=//g'` -build_shadow_skin_maxface=`cat ../../cfg/config.cfg | grep "build_shadow_skin_maxface" | sed -e 's/build_shadow_skin_maxface//' | sed -e 's/ //g' | sed -e 's/=//g'` - - -# if config wanted then must compute shadowSkin -if ( test "$do_build_shadow_skin" = "1" ) -then - for i in shape_not_optimized/*.[sS][hH][aA][pP][eE] ; do - if ( test -f $i ) - then - dest=`echo $i | sed -e 's/shape_not_optimized/shape/g'` - # if date is newer in shape_not_optimized than in shape, compute - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - # NB: overwrite shape_not_optimized, because will be cloded/copied below to shapes/ - $build_shadow_skin $i $i $build_shadow_skin_ratio $build_shadow_skin_maxface - fi - fi - done -fi - - -# Log error -echo ------- >> log.log -echo --- Build shape : Copy Shape / build CLodTex >> log.log -echo ------- >> log.log -echo ------- -echo --- Build shape : Copy Shape / build CLodTex -echo ------- -date >> log.log -date - -# Get the lod config file in the database -clod_config_file=`cat ../../cfg/config.cfg | grep "clod_config_file" | sed -e 's/clod_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# if clod cfg is setup, build clod -if (test -f $database_directory/$clod_config_file) -then - # build the shape with clod texture. convert from 'shape_not_optimized' to 'shape' - $build_clodtex -d $database_directory/$clod_config_file clod shape_not_optimized shape -else - # just copy shape_not_optimized to shape - ./sh/transfert_shape_optimize.bat -fi - -# Log error -echo ------- >> log.log -echo --- Build shape : optimize lightmaps >> log.log -echo ------- >> log.log -echo ------- -echo --- Build shape : optimize lightmaps -echo ------- -date >> log.log -date - - -# copy lightmap_not_optimized to lightmap -./sh/transfert_lightmap_optimize.bat - -quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` - -# Optimize lightmaps if any. Additionnaly, output a file indicating which lightmaps are 8 bits -$lightmap_optimizer ./lightmap ./shape ./tag ./list_lm_8bit.txt - -# Convert lightmap in 16 bits mode if they are not 8 bits lightmap - -echo ------- >> log.log -echo --- Build shape : convert lightmaps in 16 or 8 bits >> log.log -echo ------- >> log.log -echo ------- -echo --- Build shape : convert lightmaps in 16 or 8 bits -echo ------- -date >> log.log -date - -for i in lightmap/*.[tT][gG][aA] ; do - - if ( test -f $i ) - then - # Destination file - dest=`echo $i | sed -e 's/lightmap/lightmap_16_bits/g'` - - # Convert the lightmap in 16 bits mode - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - fileTest=`echo $i | sed -e 's&lightmap/&&g'` - file8Bit=`cat ./list_lm_8bit.txt | grep "$fileTest"` - if ( test "$file8Bit" = "$fileTest" ) - then - echo "export $fileTest in 8bit format" - $tga_2_dds $i -o $dest -a tga8 2>> log.log - else - echo "export $fileTest in 16bit format" - $tga_2_dds $i -o $dest -a tga16 2>> log.log - fi - fi - fi - - # Idle - ../../idle.bat -done - -# Log error -echo ------- >> log.log -echo --- Build shape : build coarse meshes >> log.log -echo ------- >> log.log -echo ------- -echo --- Build shape : build coarse meshes -echo ------- -date >> log.log -date - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get texture pathes -map_source_directories=`cat ../../cfg/directories.cfg | grep "map_source_directory" | sed -e 's/map_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the texture mul size -texture_mul_size_value=`cat ../../cfg/config.cfg | grep "texture_mul_size_value" | sed -e 's/texture_mul_size_value//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the coarse mesh texture name -coarse_mesh_texture_names=`cat ../../cfg/config.cfg | grep "coarse_mesh_texture_names" | sed -e 's/coarse_mesh_texture_names//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Copy the config file header -cat cfg/config_header.cfg | sed -e "s/texture_mul_size_value/$texture_mul_size_value/g" > cfg/config_generated.cfg - -# Corse meshes for this process ? -if ( test "$coarse_mesh_texture_names" ) then - - # Add the shape directory - echo ' "'shape_with_coarse_mesh'"', >> cfg/config_generated.cfg - - # For each texture path - for i in $map_source_directories ; do - - # Add the path - echo ' "'$database_directory/$i'"', >> cfg/config_generated.cfg - - # Idle - ../../idle.bat - done - - # Add the shape list header - echo '};' >> cfg/config_generated.cfg - echo ' ' >> cfg/config_generated.cfg - echo 'list_mesh =' >> cfg/config_generated.cfg - echo '{' >> cfg/config_generated.cfg - - # For each shape with coarse mesh - for i in shape_with_coarse_mesh/*.[sS][hH][aA][pP][eE]; do - - if ( test -f $i ) - then - # Destination file - src=`echo $i | sed -e 's&shape_with_coarse_mesh/&&g'` - dest=`echo $i | sed -e 's&shape_with_coarse_mesh&shape_with_coarse_mesh_builded&g'` - - # Add the shape - echo ' "'$src'", "'$dest'",' >> cfg/config_generated.cfg - - # Destination file - dest=`echo $i | sed -e 's/lightmap/lightmap_16_bits/g'` - fi - - # Idle - ../../idle.bat - done - echo '};' >> cfg/config_generated.cfg - - # Add output bitmap list - echo ' ' >> cfg/config_generated.cfg - echo 'output_textures = {' >> cfg/config_generated.cfg - # For each shape with coarse mesh - for i in $coarse_mesh_texture_names ; do - # Add the path - echo ' "shape_with_coarse_mesh/'$i'.tga"', >> cfg/config_generated.cfg - done - - # Close the config file - echo '};' >> cfg/config_generated.cfg - - # Execute the build - $build_coarse_mesh cfg/config_generated.cfg - - # Log error - echo ------- >> log.log - echo --- Build shape : convert coarse texture to dds without mipmaps >> log.log - echo ------- >> log.log - echo ------- - echo --- Build shape : convert coarse texture to dds without mipmaps - echo ------- - date >> log.log - date - - # Convert the coarse texture to dds - for i in $coarse_mesh_texture_names ; do - if ( test -f shape_with_coarse_mesh/$i.tga ) - then - $tga_2_dds shape_with_coarse_mesh/$i.tga -o shape_with_coarse_mesh_builded/$i.dds -a 5 2>> log.log - fi - done - -else - - echo --- No coarse meshes texture defined >> log.log - echo --- No coarse meshes texture defined - -fi +#!/bin/bash +rm log.log 2> /dev/null + +# *** Build shape files (.shape) + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Bin +tga_2_dds='tga2dds.exe' +build_coarse_mesh='build_coarse_mesh.exe' +lightmap_optimizer='lightmap_optimizer.exe' +build_clodtex='build_clodtex.exe' +build_shadow_skin='build_shadow_skin.exe' + +# Log error +echo ------- > log.log +echo --- Build ShadowSkin shape >> log.log +echo ------- >> log.log +echo ------- +echo --- Build ShadowSkin shape +echo ------- +date >> log.log +date + +# build shadow skin? +do_build_shadow_skin=`cat ../../cfg/config.cfg | grep -w "build_shadow_skin" | sed -e 's/build_shadow_skin//' | sed -e 's/ //g' | sed -e 's/=//g'` +build_shadow_skin_ratio=`cat ../../cfg/config.cfg | grep "build_shadow_skin_ratio" | sed -e 's/build_shadow_skin_ratio//' | sed -e 's/ //g' | sed -e 's/=//g'` +build_shadow_skin_maxface=`cat ../../cfg/config.cfg | grep "build_shadow_skin_maxface" | sed -e 's/build_shadow_skin_maxface//' | sed -e 's/ //g' | sed -e 's/=//g'` + + +# if config wanted then must compute shadowSkin +if ( test "$do_build_shadow_skin" = "1" ) +then + for i in shape_not_optimized/*.[sS][hH][aA][pP][eE] ; do + if ( test -f $i ) + then + dest=`echo $i | sed -e 's/shape_not_optimized/shape/g'` + # if date is newer in shape_not_optimized than in shape, compute + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + # NB: overwrite shape_not_optimized, because will be cloded/copied below to shapes/ + $build_shadow_skin $i $i $build_shadow_skin_ratio $build_shadow_skin_maxface + fi + fi + done +fi + + +# Log error +echo ------- >> log.log +echo --- Build shape : Copy Shape / build CLodTex >> log.log +echo ------- >> log.log +echo ------- +echo --- Build shape : Copy Shape / build CLodTex +echo ------- +date >> log.log +date + +# Get the lod config file in the database +clod_config_file=`cat ../../cfg/config.cfg | grep "clod_config_file" | sed -e 's/clod_config_file//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# if clod cfg is setup, build clod +if (test -f $database_directory/$clod_config_file) +then + # build the shape with clod texture. convert from 'shape_not_optimized' to 'shape' + $build_clodtex -d $database_directory/$clod_config_file clod shape_not_optimized shape +else + # just copy shape_not_optimized to shape + ./sh/transfert_shape_optimize.bat +fi + +# Log error +echo ------- >> log.log +echo --- Build shape : optimize lightmaps >> log.log +echo ------- >> log.log +echo ------- +echo --- Build shape : optimize lightmaps +echo ------- +date >> log.log +date + + +# copy lightmap_not_optimized to lightmap +./sh/transfert_lightmap_optimize.bat + +quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` + +# Optimize lightmaps if any. Additionnaly, output a file indicating which lightmaps are 8 bits +$lightmap_optimizer ./lightmap ./shape ./tag ./list_lm_8bit.txt + +# Convert lightmap in 16 bits mode if they are not 8 bits lightmap + +echo ------- >> log.log +echo --- Build shape : convert lightmaps in 16 or 8 bits >> log.log +echo ------- >> log.log +echo ------- +echo --- Build shape : convert lightmaps in 16 or 8 bits +echo ------- +date >> log.log +date + +for i in lightmap/*.[tT][gG][aA] ; do + + if ( test -f $i ) + then + # Destination file + dest=`echo $i | sed -e 's/lightmap/lightmap_16_bits/g'` + + # Convert the lightmap in 16 bits mode + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + fileTest=`echo $i | sed -e 's&lightmap/&&g'` + file8Bit=`cat ./list_lm_8bit.txt | grep "$fileTest"` + if ( test "$file8Bit" = "$fileTest" ) + then + echo "export $fileTest in 8bit format" + $tga_2_dds $i -o $dest -a tga8 2>> log.log + else + echo "export $fileTest in 16bit format" + $tga_2_dds $i -o $dest -a tga16 2>> log.log + fi + fi + fi + + # Idle + ../../idle.bat +done + +# Log error +echo ------- >> log.log +echo --- Build shape : build coarse meshes >> log.log +echo ------- >> log.log +echo ------- +echo --- Build shape : build coarse meshes +echo ------- +date >> log.log +date + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get texture pathes +map_source_directories=`cat ../../cfg/directories.cfg | grep "map_source_directory" | sed -e 's/map_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the texture mul size +texture_mul_size_value=`cat ../../cfg/config.cfg | grep "texture_mul_size_value" | sed -e 's/texture_mul_size_value//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the coarse mesh texture name +coarse_mesh_texture_names=`cat ../../cfg/config.cfg | grep "coarse_mesh_texture_names" | sed -e 's/coarse_mesh_texture_names//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Copy the config file header +cat cfg/config_header.cfg | sed -e "s/texture_mul_size_value/$texture_mul_size_value/g" > cfg/config_generated.cfg + +# Corse meshes for this process ? +if ( test "$coarse_mesh_texture_names" ) then + + # Add the shape directory + echo ' "'shape_with_coarse_mesh'"', >> cfg/config_generated.cfg + + # For each texture path + for i in $map_source_directories ; do + + # Add the path + echo ' "'$database_directory/$i'"', >> cfg/config_generated.cfg + + # Idle + ../../idle.bat + done + + # Add the shape list header + echo '};' >> cfg/config_generated.cfg + echo ' ' >> cfg/config_generated.cfg + echo 'list_mesh =' >> cfg/config_generated.cfg + echo '{' >> cfg/config_generated.cfg + + # For each shape with coarse mesh + for i in shape_with_coarse_mesh/*.[sS][hH][aA][pP][eE]; do + + if ( test -f $i ) + then + # Destination file + src=`echo $i | sed -e 's&shape_with_coarse_mesh/&&g'` + dest=`echo $i | sed -e 's&shape_with_coarse_mesh&shape_with_coarse_mesh_builded&g'` + + # Add the shape + echo ' "'$src'", "'$dest'",' >> cfg/config_generated.cfg + + # Destination file + dest=`echo $i | sed -e 's/lightmap/lightmap_16_bits/g'` + fi + + # Idle + ../../idle.bat + done + echo '};' >> cfg/config_generated.cfg + + # Add output bitmap list + echo ' ' >> cfg/config_generated.cfg + echo 'output_textures = {' >> cfg/config_generated.cfg + # For each shape with coarse mesh + for i in $coarse_mesh_texture_names ; do + # Add the path + echo ' "shape_with_coarse_mesh/'$i'.tga"', >> cfg/config_generated.cfg + done + + # Close the config file + echo '};' >> cfg/config_generated.cfg + + # Execute the build + $build_coarse_mesh cfg/config_generated.cfg + + # Log error + echo ------- >> log.log + echo --- Build shape : convert coarse texture to dds without mipmaps >> log.log + echo ------- >> log.log + echo ------- + echo --- Build shape : convert coarse texture to dds without mipmaps + echo ------- + date >> log.log + date + + # Convert the coarse texture to dds + for i in $coarse_mesh_texture_names ; do + if ( test -f shape_with_coarse_mesh/$i.tga ) + then + $tga_2_dds shape_with_coarse_mesh/$i.tga -o shape_with_coarse_mesh_builded/$i.dds -a 5 2>> log.log + fi + done + +else + + echo --- No coarse meshes texture defined >> log.log + echo --- No coarse meshes texture defined + +fi diff --git a/nel/tools/3d/build_gamedata/processes/shape/sh/export.sh b/nel/tools/3d/build_gamedata/processes/shape/sh/export.sh index 73ab93589..d00c71ac7 100644 --- a/nel/tools/3d/build_gamedata/processes/shape/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/shape/sh/export.sh @@ -1,140 +1,140 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# ********************************************* -# ********************************************* -# *** Export shape files (.shape) from Max -# ********************************************* -# ********************************************* - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "shape_export_timeout" | sed -e 's/shape_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the shape directories -shape_source_directories=`cat ../../cfg/directories.cfg | grep "shape_source_directory" | sed -e 's/shape_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the quality option to choose the goor properties.cfg file -quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Get the options -if ( test "$quality_flag" ) -then - # We are in BEST mode - seoel=`cat ../../cfg/config.cfg | grep "shape_export_opt_export_lighting" | sed -e 's/shape_export_opt_export_lighting//' | sed -e 's/ //g' | sed -e 's/=//g'` - seos=`cat ../../cfg/config.cfg | grep "shape_export_opt_shadow" | sed -e 's/shape_export_opt_shadow//' | sed -e 's/ //g' | sed -e 's/=//g'` - seoll=`cat ../../cfg/config.cfg | grep "shape_export_opt_lighting_limit" | sed -e 's/shape_export_opt_lighting_limit//' | sed -e 's/ //g' | sed -e 's/=//g'` - seols=`cat ../../cfg/config.cfg | grep "shape_export_opt_lumel_size" | sed -e 's/shape_export_opt_lumel_size//' | sed -e 's/ //g' | sed -e 's/=//g'` - seoo=`cat ../../cfg/config.cfg | grep "shape_export_opt_oversampling" | sed -e 's/shape_export_opt_oversampling//' | sed -e 's/ //g' | sed -e 's/=//g'` -else - # We are in DRAFT mode - seoel='false' - seos='false' - seoll='0' - seols='0.25' - seoo='1' -fi - seolog=`cat ../../cfg/config.cfg | grep "shape_export_opt_lightmap_log" | sed -e 's/shape_export_opt_lightmap_log//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export shape >> log.log -echo ------- >> log.log -echo ------- -echo --- Export shape -echo ------- -date >> log.log -date - -# For each directoy - -for i in $shape_source_directories ; do - # Copy the script - cat maxscript/shape_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/shape/log.log&g" | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g" | sed -e "s&output_directory_without_coarse_mesh&$build_gamedata_directory/processes/shape/shape_not_optimized&g" | sed -e "s&output_directory_with_coarse_mesh&$build_gamedata_directory/processes/shape/shape_with_coarse_mesh&g" | sed -e "s&shape_export_opt_export_lighting&$seoel&g" | sed -e "s&shape_export_opt_shadow&$seos&g" | sed -e "s&shape_export_opt_lighting_limit&$seoll&g" | sed -e "s&shape_export_opt_lumel_size&$seols&g" | sed -e "s&shape_export_opt_oversampling&$seoo&g"| sed -e "s&shape_export_opt_lightmap_log&$seolog&g" | sed -e "s&shape_lightmap_path&$build_gamedata_directory/processes/shape/lightmap_not_optimized&g" | sed -e "s&output_directory_anim&$build_gamedata_directory/processes/shape/anim&g" > $max_directory/scripts/shape_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - - -# ********************************************* -# ********************************************* -# *** Export character lod shape files (.clod) from Max -# ********************************************* -# ********************************************* - -# Get the clod directories -clod_source_directories=`cat ../../cfg/directories.cfg | grep "clod_source_directory" | sed -e 's/clod_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- >> log.log -echo --- Export clod >> log.log -echo ------- >> log.log -echo ------- -echo --- Export clod -echo ------- -date >> log.log -date - -# For each directoy - -for i in $clod_source_directories ; do - # Copy the script. TAKE IT FROM clodbank process. But write it here. - cat ../clodbank/maxscript/clod_export.ms | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_clod&$build_gamedata_directory/processes/shape/clod&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g" > $max_directory/scripts/clod_export.ms - - # Start max - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Concat log.log files - echo Try 1 >> log.log - cat $max_directory/log.log >> log.log - - # Idle - ../../idle.bat - - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Concat log.log files - echo Try 2 >> log.log - cat $max_directory/log.log >> log.log - - # Idle - ../../idle.bat - - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn - - # Concat log.log files - echo Try 3 >> log.log - cat $max_directory/log.log >> log.log - - # Idle - ../../idle.bat -done - - +#!/bin/bash +rm log.log 2> /dev/null + +# ********************************************* +# ********************************************* +# *** Export shape files (.shape) from Max +# ********************************************* +# ********************************************* + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "shape_export_timeout" | sed -e 's/shape_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the shape directories +shape_source_directories=`cat ../../cfg/directories.cfg | grep "shape_source_directory" | sed -e 's/shape_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the quality option to choose the goor properties.cfg file +quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Get the options +if ( test "$quality_flag" ) +then + # We are in BEST mode + seoel=`cat ../../cfg/config.cfg | grep "shape_export_opt_export_lighting" | sed -e 's/shape_export_opt_export_lighting//' | sed -e 's/ //g' | sed -e 's/=//g'` + seos=`cat ../../cfg/config.cfg | grep "shape_export_opt_shadow" | sed -e 's/shape_export_opt_shadow//' | sed -e 's/ //g' | sed -e 's/=//g'` + seoll=`cat ../../cfg/config.cfg | grep "shape_export_opt_lighting_limit" | sed -e 's/shape_export_opt_lighting_limit//' | sed -e 's/ //g' | sed -e 's/=//g'` + seols=`cat ../../cfg/config.cfg | grep "shape_export_opt_lumel_size" | sed -e 's/shape_export_opt_lumel_size//' | sed -e 's/ //g' | sed -e 's/=//g'` + seoo=`cat ../../cfg/config.cfg | grep "shape_export_opt_oversampling" | sed -e 's/shape_export_opt_oversampling//' | sed -e 's/ //g' | sed -e 's/=//g'` +else + # We are in DRAFT mode + seoel='false' + seos='false' + seoll='0' + seols='0.25' + seoo='1' +fi + seolog=`cat ../../cfg/config.cfg | grep "shape_export_opt_lightmap_log" | sed -e 's/shape_export_opt_lightmap_log//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export shape >> log.log +echo ------- >> log.log +echo ------- +echo --- Export shape +echo ------- +date >> log.log +date + +# For each directoy + +for i in $shape_source_directories ; do + # Copy the script + cat maxscript/shape_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/shape/log.log&g" | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g" | sed -e "s&output_directory_without_coarse_mesh&$build_gamedata_directory/processes/shape/shape_not_optimized&g" | sed -e "s&output_directory_with_coarse_mesh&$build_gamedata_directory/processes/shape/shape_with_coarse_mesh&g" | sed -e "s&shape_export_opt_export_lighting&$seoel&g" | sed -e "s&shape_export_opt_shadow&$seos&g" | sed -e "s&shape_export_opt_lighting_limit&$seoll&g" | sed -e "s&shape_export_opt_lumel_size&$seols&g" | sed -e "s&shape_export_opt_oversampling&$seoo&g"| sed -e "s&shape_export_opt_lightmap_log&$seolog&g" | sed -e "s&shape_lightmap_path&$build_gamedata_directory/processes/shape/lightmap_not_optimized&g" | sed -e "s&output_directory_anim&$build_gamedata_directory/processes/shape/anim&g" > $max_directory/scripts/shape_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript shape_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + + +# ********************************************* +# ********************************************* +# *** Export character lod shape files (.clod) from Max +# ********************************************* +# ********************************************* + +# Get the clod directories +clod_source_directories=`cat ../../cfg/directories.cfg | grep "clod_source_directory" | sed -e 's/clod_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- >> log.log +echo --- Export clod >> log.log +echo ------- >> log.log +echo ------- +echo --- Export clod +echo ------- +date >> log.log +date + +# For each directoy + +for i in $clod_source_directories ; do + # Copy the script. TAKE IT FROM clodbank process. But write it here. + cat ../clodbank/maxscript/clod_export.ms | sed -e "s&shape_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_clod&$build_gamedata_directory/processes/shape/clod&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g" > $max_directory/scripts/clod_export.ms + + # Start max + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Concat log.log files + echo Try 1 >> log.log + cat $max_directory/log.log >> log.log + + # Idle + ../../idle.bat + + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Concat log.log files + echo Try 2 >> log.log + cat $max_directory/log.log >> log.log + + # Idle + ../../idle.bat + + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript clod_export.ms -q -mi -vn + + # Concat log.log files + echo Try 3 >> log.log + cat $max_directory/log.log >> log.log + + # Idle + ../../idle.bat +done + + diff --git a/nel/tools/3d/build_gamedata/processes/shape/sh/install.sh b/nel/tools/3d/build_gamedata/processes/shape/sh/install.sh index 542138370..a7e3ba255 100644 --- a/nel/tools/3d/build_gamedata/processes/shape/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/shape/sh/install.sh @@ -1,36 +1,36 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install shapes in the client data - -# Get the shape install directory -shape_install_directory=`cat ../../cfg/directories.cfg | grep "shape_install_directory" | sed -e 's/shape_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the lightmaps install directory -lightmap_install_directory=`cat ../../cfg/directories.cfg | grep "lightmap_install_directory" | sed -e 's/lightmap_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install Shape >> log.log -echo ------- >> log.log -echo ------- -echo --- Install Shape -echo ------- -date >> log.log -date - - -cp -u -p -R shape/. $client_directory/$shape_install_directory 2>> log.log -cp -u -p -R shape_with_coarse_mesh_builded/. $client_directory/$shape_install_directory 2>> log.log - -if test "$lightmap_install_directory"; then - mkdir $client_directory/$lightmap_install_directory 2>> log.log 2> /dev/null - cp -u -p -R lightmap_16_bits/. $client_directory/$lightmap_install_directory 2>> log.log -fi - -cp -u -p -R anim/. $client_directory/$shape_install_directory 2>> log.log - -ls anim | grep ".anim" >> $client_directory/auto_animations_list.txt +#!/bin/bash +rm log.log 2> /dev/null + +# Install shapes in the client data + +# Get the shape install directory +shape_install_directory=`cat ../../cfg/directories.cfg | grep "shape_install_directory" | sed -e 's/shape_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the lightmaps install directory +lightmap_install_directory=`cat ../../cfg/directories.cfg | grep "lightmap_install_directory" | sed -e 's/lightmap_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install Shape >> log.log +echo ------- >> log.log +echo ------- +echo --- Install Shape +echo ------- +date >> log.log +date + + +cp -u -p -R shape/. $client_directory/$shape_install_directory 2>> log.log +cp -u -p -R shape_with_coarse_mesh_builded/. $client_directory/$shape_install_directory 2>> log.log + +if test "$lightmap_install_directory"; then + mkdir $client_directory/$lightmap_install_directory 2>> log.log 2> /dev/null + cp -u -p -R lightmap_16_bits/. $client_directory/$lightmap_install_directory 2>> log.log +fi + +cp -u -p -R anim/. $client_directory/$shape_install_directory 2>> log.log + +ls anim | grep ".anim" >> $client_directory/auto_animations_list.txt diff --git a/nel/tools/3d/build_gamedata/processes/skel/sh/export.sh b/nel/tools/3d/build_gamedata/processes/skel/sh/export.sh index 5039f8ffd..f3a1a7e4f 100644 --- a/nel/tools/3d/build_gamedata/processes/skel/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/skel/sh/export.sh @@ -1,80 +1,80 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export skeleton files (.skel) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "skel_export_timeout" | sed -e 's/skel_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the skel directories -skel_source_directories=`cat ../../cfg/directories.cfg | grep "skel_source_directory" | sed -e 's/skel_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export skeleton from MAX>> log.log -echo ------- >> log.log -echo ------- -echo --- Export skeleton from MAX -echo ------- -date >> log.log -date - -# For each directoy - -for i in $skel_source_directories ; do - # Copy the script - cat maxscript/skel_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/skel/log.log&g" | sed -e "s&skel_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/skel/skel&g" > $max_directory/scripts/skel_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - - -# *** Export skeleton files (.skel) directly from .skel version - -# Log error -echo ------- >> log.log -echo --- Copy skeleton from .skel>> log.log -echo ------- >> log.log -echo ------- -echo --- Copy skeleton from .skel -echo ------- -date >> log.log -date - -# For each directoy - -for i in $skel_source_directories ; do - # copy - cp -u -p $database_directory/$i/*.[sS][kK][eE][lL] skel 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export skeleton files (.skel) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "skel_export_timeout" | sed -e 's/skel_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the skel directories +skel_source_directories=`cat ../../cfg/directories.cfg | grep "skel_source_directory" | sed -e 's/skel_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export skeleton from MAX>> log.log +echo ------- >> log.log +echo ------- +echo --- Export skeleton from MAX +echo ------- +date >> log.log +date + +# For each directoy + +for i in $skel_source_directories ; do + # Copy the script + cat maxscript/skel_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/skel/log.log&g" | sed -e "s&skel_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/skel/skel&g" > $max_directory/scripts/skel_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript skel_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + + +# *** Export skeleton files (.skel) directly from .skel version + +# Log error +echo ------- >> log.log +echo --- Copy skeleton from .skel>> log.log +echo ------- >> log.log +echo ------- +echo --- Copy skeleton from .skel +echo ------- +date >> log.log +date + +# For each directoy + +for i in $skel_source_directories ; do + # copy + cp -u -p $database_directory/$i/*.[sS][kK][eE][lL] skel 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/skel/sh/install.sh b/nel/tools/3d/build_gamedata/processes/skel/sh/install.sh index f93c9e431..d1ce0a9de 100644 --- a/nel/tools/3d/build_gamedata/processes/skel/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/skel/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install skel in the client data - -# Get the skel install directory -skel_install_directory=`cat ../../cfg/directories.cfg | grep "skel_install_directory" | sed -e 's/skel_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install skeleton >> log.log -echo ------- >> log.log -echo ------- -echo --- Install skeleton -echo ------- -date >> log.log -date - -cp -u -p -R skel/. $client_directory/$skel_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install skel in the client data + +# Get the skel install directory +skel_install_directory=`cat ../../cfg/directories.cfg | grep "skel_install_directory" | sed -e 's/skel_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install skeleton >> log.log +echo ------- >> log.log +echo ------- +echo --- Install skeleton +echo ------- +date >> log.log +date + +cp -u -p -R skel/. $client_directory/$skel_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/smallbank/sh/export.sh b/nel/tools/3d/build_gamedata/processes/smallbank/sh/export.sh index c07fc24e3..1c594ef5d 100644 --- a/nel/tools/3d/build_gamedata/processes/smallbank/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/smallbank/sh/export.sh @@ -1,72 +1,72 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export bank file (.bank) from Max - -# Some exe -build_smallbank='build_smallbank.exe' -exec_timeout='exec_timeout.exe' - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the swt directories -bank_source_directory=`cat ../../cfg/directories.cfg | grep "bank_source_directory" | sed -e 's/bank_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "smallbank_build_timeout" | sed -e 's/smallbank_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the tiles root directories -tile_root_source_directory=`cat ../../cfg/directories.cfg | grep "tile_root_source_directory" | sed -e 's/tile_root_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export bank >> log.log -echo ------- >> log.log -echo ------- -echo --- Export bank -echo ------- -date >> log.log -date - -# Copy the bank -cp -u -p $database_directory/$bank_source_directory/*.[bB][aA][nN][kK] bank 2>> log.log - -# Build the small bank - -# Log error -echo ------- > log.log -echo --- Build bank >> log.log -echo ------- >> log.log -echo ------- -echo --- Build bank -echo ------- -date >> log.log -date - -# list all the bank -bank_list=`ls -1 bank/*.[bB][aA][nN][kK]` - -# For each bank -for i in $bank_list ; do - # Destination the name - dest=`echo $i | sed -e 's&bank&smallbank&g'` - - # Make the dependencies - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - $exec_timeout $timeout $build_smallbank $i $dest $database_directory/$tile_root_source_directory/ - if ( test -e $dest ) - then - echo OK $dest >> log.log - else - echo ERROR building $dest >> log.log - fi - else - echo SKIPPED $dest >> log.log - fi - - # Idle - ../../idle.bat -done - +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export bank file (.bank) from Max + +# Some exe +build_smallbank='build_smallbank.exe' +exec_timeout='exec_timeout.exe' + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the swt directories +bank_source_directory=`cat ../../cfg/directories.cfg | grep "bank_source_directory" | sed -e 's/bank_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "smallbank_build_timeout" | sed -e 's/smallbank_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the tiles root directories +tile_root_source_directory=`cat ../../cfg/directories.cfg | grep "tile_root_source_directory" | sed -e 's/tile_root_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export bank >> log.log +echo ------- >> log.log +echo ------- +echo --- Export bank +echo ------- +date >> log.log +date + +# Copy the bank +cp -u -p $database_directory/$bank_source_directory/*.[bB][aA][nN][kK] bank 2>> log.log + +# Build the small bank + +# Log error +echo ------- > log.log +echo --- Build bank >> log.log +echo ------- >> log.log +echo ------- +echo --- Build bank +echo ------- +date >> log.log +date + +# list all the bank +bank_list=`ls -1 bank/*.[bB][aA][nN][kK]` + +# For each bank +for i in $bank_list ; do + # Destination the name + dest=`echo $i | sed -e 's&bank&smallbank&g'` + + # Make the dependencies + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + $exec_timeout $timeout $build_smallbank $i $dest $database_directory/$tile_root_source_directory/ + if ( test -e $dest ) + then + echo OK $dest >> log.log + else + echo ERROR building $dest >> log.log + fi + else + echo SKIPPED $dest >> log.log + fi + + # Idle + ../../idle.bat +done + diff --git a/nel/tools/3d/build_gamedata/processes/smallbank/sh/install.sh b/nel/tools/3d/build_gamedata/processes/smallbank/sh/install.sh index 1bf703581..d0e4634fb 100644 --- a/nel/tools/3d/build_gamedata/processes/smallbank/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/smallbank/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the bank in the client data - -# Get the bank install directory -bank_install_directory=`cat ../../cfg/directories.cfg | grep "bank_install_directory" | sed -e 's/bank_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install smallbank >> log.log -echo ------- >> log.log -echo ------- -echo --- Install smallbank -echo ------- -date >> log.log -date - -cp -u -p -R smallbank/. $client_directory/$bank_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the bank in the client data + +# Get the bank install directory +bank_install_directory=`cat ../../cfg/directories.cfg | grep "bank_install_directory" | sed -e 's/bank_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install smallbank >> log.log +echo ------- >> log.log +echo ------- +echo --- Install smallbank +echo ------- +date >> log.log +date + +cp -u -p -R smallbank/. $client_directory/$bank_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/swt/sh/export.sh b/nel/tools/3d/build_gamedata/processes/swt/sh/export.sh index 2855f8548..3b33cf45b 100644 --- a/nel/tools/3d/build_gamedata/processes/swt/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/swt/sh/export.sh @@ -1,57 +1,57 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export skeleton weight files (.swt) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "swt_export_timeout" | sed -e 's/swt_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the swt directories -swt_source_directories=`cat ../../cfg/directories.cfg | grep "swt_source_directory" | sed -e 's/swt_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export skeleton weight >> log.log -echo ------- >> log.log -echo ------- -echo --- Export skeleton weight -echo ------- -date >> log.log -date - -# For each directoy - -for i in $swt_source_directories ; do - # Copy the script - cat maxscript/swt_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/swt/log.log&g" | sed -e "s&swt_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/swt/swt&g" > $max_directory/scripts/swt_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export skeleton weight files (.swt) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "swt_export_timeout" | sed -e 's/swt_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the swt directories +swt_source_directories=`cat ../../cfg/directories.cfg | grep "swt_source_directory" | sed -e 's/swt_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export skeleton weight >> log.log +echo ------- >> log.log +echo ------- +echo --- Export skeleton weight +echo ------- +date >> log.log +date + +# For each directoy + +for i in $swt_source_directories ; do + # Copy the script + cat maxscript/swt_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/swt/log.log&g" | sed -e "s&swt_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/swt/swt&g" > $max_directory/scripts/swt_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript swt_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/swt/sh/install.sh b/nel/tools/3d/build_gamedata/processes/swt/sh/install.sh index 78aacb4be..a7882ce26 100644 --- a/nel/tools/3d/build_gamedata/processes/swt/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/swt/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install swt in the client data - -# Get the swt install directory -swt_install_directory=`cat ../../cfg/directories.cfg | grep "swt_install_directory" | sed -e 's/swt_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install skeleton weight >> log.log -echo ------- >> log.log -echo ------- -echo --- Install skeleton weight -echo ------- -date >> log.log -date - -cp -u -p -R swt/. $client_directory/$swt_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install swt in the client data + +# Get the swt install directory +swt_install_directory=`cat ../../cfg/directories.cfg | grep "swt_install_directory" | sed -e 's/swt_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install skeleton weight >> log.log +echo ------- >> log.log +echo ------- +echo --- Install skeleton weight +echo ------- +date >> log.log +date + +cp -u -p -R swt/. $client_directory/$swt_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/tiles/sh/build.sh b/nel/tools/3d/build_gamedata/processes/tiles/sh/build.sh index 99be397c3..a8e346450 100644 --- a/nel/tools/3d/build_gamedata/processes/tiles/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/tiles/sh/build.sh @@ -1,43 +1,43 @@ -#!/bin/bash -rm log.log 2> /dev/null - -tga_2_dds='tga2dds.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "maps_build_timeout" | sed -e 's/maps_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Build the tile textures - -# Log error -echo ------- > log.log -echo --- Build tiles >> log.log -echo ------- >> log.log -echo ------- -echo --- Build tiles -echo ------- -date >> log.log -date - -# For each texture -for i in maps_tga/*.[tT][gG][aA] ; do - if ( test -e $i ) - then - dest=`echo $i | sed -e 's/maps_tga/maps_final/g' | sed -e 's/.tga/.dds/g'` - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - $exec_timeout $timeout $tga_2_dds $i -o $dest -a 5 -m - if ( test -e $dest ) - then - echo OK $dest >> log.log - else - echo ERROR building $dest >> log.log - fi - else - echo SKIPPED $dest >> log.log - fi - fi - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +tga_2_dds='tga2dds.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "maps_build_timeout" | sed -e 's/maps_build_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Build the tile textures + +# Log error +echo ------- > log.log +echo --- Build tiles >> log.log +echo ------- >> log.log +echo ------- +echo --- Build tiles +echo ------- +date >> log.log +date + +# For each texture +for i in maps_tga/*.[tT][gG][aA] ; do + if ( test -e $i ) + then + dest=`echo $i | sed -e 's/maps_tga/maps_final/g' | sed -e 's/.tga/.dds/g'` + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + $exec_timeout $timeout $tga_2_dds $i -o $dest -a 5 -m + if ( test -e $dest ) + then + echo OK $dest >> log.log + else + echo ERROR building $dest >> log.log + fi + else + echo SKIPPED $dest >> log.log + fi + fi + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/tiles/sh/export.sh b/nel/tools/3d/build_gamedata/processes/tiles/sh/export.sh index b26e5adf0..a6e03995f 100644 --- a/nel/tools/3d/build_gamedata/processes/tiles/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/tiles/sh/export.sh @@ -1,33 +1,33 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Export the tile textures - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the tile directories -tile_source_directories=`cat ../../cfg/directories.cfg | grep "tile_source_directories" | sed -e 's/tile_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export tiles >> log.log -echo ------- >> log.log -echo ------- -echo --- Export tiles -echo ------- -date >> log.log -date - -# For each directoy -for i in $tile_source_directories ; do - list_textures=`find $database_directory/$i -type f -name '*.[tT][gG][aA]'` - - # For each textures - for j in $list_textures ; do - cp -u -p $j maps_tga/ 2>> log.log - done - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# Export the tile textures + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the tile directories +tile_source_directories=`cat ../../cfg/directories.cfg | grep "tile_source_directories" | sed -e 's/tile_source_directories//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export tiles >> log.log +echo ------- >> log.log +echo ------- +echo --- Export tiles +echo ------- +date >> log.log +date + +# For each directoy +for i in $tile_source_directories ; do + list_textures=`find $database_directory/$i -type f -name '*.[tT][gG][aA]'` + + # For each textures + for j in $list_textures ; do + cp -u -p $j maps_tga/ 2>> log.log + done + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/tiles/sh/install.sh b/nel/tools/3d/build_gamedata/processes/tiles/sh/install.sh index bb5263f3e..6168aa3e4 100644 --- a/nel/tools/3d/build_gamedata/processes/tiles/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/tiles/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install tiles in the client data - -# Get the tile install directory -tile_install_directory=`cat ../../cfg/directories.cfg | grep "tile_install_directory" | sed -e 's/tile_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install Tiles >> log.log -echo ------- >> log.log -echo ------- -echo --- Install Tiles -echo ------- -date >> log.log -date - -cp -u -p -R maps_final/. $client_directory/$tile_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install tiles in the client data + +# Get the tile install directory +tile_install_directory=`cat ../../cfg/directories.cfg | grep "tile_install_directory" | sed -e 's/tile_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install Tiles >> log.log +echo ------- >> log.log +echo ------- +echo --- Install Tiles +echo ------- +date >> log.log +date + +cp -u -p -R maps_final/. $client_directory/$tile_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/veget/sh/export.sh b/nel/tools/3d/build_gamedata/processes/veget/sh/export.sh index 036a53b17..2bb35f60d 100644 --- a/nel/tools/3d/build_gamedata/processes/veget/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/veget/sh/export.sh @@ -1,52 +1,52 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export veget files (.veget) from Max - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the veget directories -veget_source_directories=`cat ../../cfg/directories.cfg | grep "veget_source_directory" | sed -e 's/veget_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -# Log error -echo ------- > log.log -echo --- Export veget >> log.log -echo ------- >> log.log -echo ------- -echo --- Export veget -echo ------- -date >> log.log -date - -# For each directoy - -for i in $veget_source_directories ; do - # Copy the script - cat maxscript/veget_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/veget/log.log&g" | sed -e "s&veget_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_veget&$build_gamedata_directory/processes/veget/veget&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/veget/tag&g" > $max_directory/scripts/veget_export.ms - - # Start max - echo Try 1 >> log.log - $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 2 >> log.log - $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn - - # Idle - ../../idle.bat - - echo Try 3 >> log.log - $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export veget files (.veget) from Max + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the veget directories +veget_source_directories=`cat ../../cfg/directories.cfg | grep "veget_source_directory" | sed -e 's/veget_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +# Log error +echo ------- > log.log +echo --- Export veget >> log.log +echo ------- >> log.log +echo ------- +echo --- Export veget +echo ------- +date >> log.log +date + +# For each directoy + +for i in $veget_source_directories ; do + # Copy the script + cat maxscript/veget_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/veget/log.log&g" | sed -e "s&veget_source_directory&$database_directory/$i&g" | sed -e "s&output_directory_veget&$build_gamedata_directory/processes/veget/veget&g" | sed -e "s&output_directory_tag&$build_gamedata_directory/processes/veget/tag&g" > $max_directory/scripts/veget_export.ms + + # Start max + echo Try 1 >> log.log + $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 2 >> log.log + $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn + + # Idle + ../../idle.bat + + echo Try 3 >> log.log + $max_directory/3dsmax.exe -U MAXScript veget_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/veget/sh/install.sh b/nel/tools/3d/build_gamedata/processes/veget/sh/install.sh index dc4551040..509a07960 100644 --- a/nel/tools/3d/build_gamedata/processes/veget/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/veget/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install vegets in the client data - -# Get the veget install directory -veget_install_directory=`cat ../../cfg/directories.cfg | grep "veget_install_directory" | sed -e 's/veget_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install veget >> log.log -echo ------- >> log.log -echo ------- -echo --- Install veget -echo ------- -date >> log.log -date - -cp -u -p -R veget/. $client_directory/$veget_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install vegets in the client data + +# Get the veget install directory +veget_install_directory=`cat ../../cfg/directories.cfg | grep "veget_install_directory" | sed -e 's/veget_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install veget >> log.log +echo ------- >> log.log +echo ------- +echo --- Install veget +echo ------- +date >> log.log +date + +cp -u -p -R veget/. $client_directory/$veget_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/vegetset/sh/export.sh b/nel/tools/3d/build_gamedata/processes/vegetset/sh/export.sh index 57c42cab0..fffb86416 100644 --- a/nel/tools/3d/build_gamedata/processes/vegetset/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/vegetset/sh/export.sh @@ -1,29 +1,29 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export vegetset file (.vegetset) - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the vegetset directories -vegetset_source_directories=`cat ../../cfg/directories.cfg | grep "vegetset_source_directory" | sed -e 's/vegetset_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export vegetset >> log.log -echo ------- >> log.log -echo ------- -echo --- Export vegetset -echo ------- -date >> log.log -date - -# For each vegetset directory -for i in $vegetset_source_directories ; do - # Copy - cp -u -p $database_directory/$i/*.[vV][eE][gG][eE][tT][sS][eE][tT] vegetset 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export vegetset file (.vegetset) + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the vegetset directories +vegetset_source_directories=`cat ../../cfg/directories.cfg | grep "vegetset_source_directory" | sed -e 's/vegetset_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export vegetset >> log.log +echo ------- >> log.log +echo ------- +echo --- Export vegetset +echo ------- +date >> log.log +date + +# For each vegetset directory +for i in $vegetset_source_directories ; do + # Copy + cp -u -p $database_directory/$i/*.[vV][eE][gG][eE][tT][sS][eE][tT] vegetset 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/vegetset/sh/install.sh b/nel/tools/3d/build_gamedata/processes/vegetset/sh/install.sh index 8aa214eb6..44678768f 100644 --- a/nel/tools/3d/build_gamedata/processes/vegetset/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/vegetset/sh/install.sh @@ -1,22 +1,22 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the vegetable set in the client data - -# Get the vegetset install directory -vegetset_install_directory=`cat ../../cfg/directories.cfg | grep "vegetset_install_directory" | sed -e 's/vegetset_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install vegetset >> log.log -echo ------- >> log.log -echo ------- -echo --- Install vegetset -echo ------- -date >> log.log -date - -cp -u -p -R vegetset/. $client_directory/$vegetset_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the vegetable set in the client data + +# Get the vegetset install directory +vegetset_install_directory=`cat ../../cfg/directories.cfg | grep "vegetset_install_directory" | sed -e 's/vegetset_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install vegetset >> log.log +echo ------- >> log.log +echo ------- +echo --- Install vegetset +echo ------- +date >> log.log +date + +cp -u -p -R vegetset/. $client_directory/$vegetset_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/zone/sh/build.sh b/nel/tools/3d/build_gamedata/processes/zone/sh/build.sh index f3b32f17d..2657c0b42 100644 --- a/nel/tools/3d/build_gamedata/processes/zone/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/zone/sh/build.sh @@ -1,149 +1,149 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build zone - -zone_dependencies='zone_dependencies.exe' -zone_welder='zone_welder.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -depend_timeout=`cat ../../cfg/config.cfg | grep "zone_build_depend_timeout" | sed -e 's/zone_build_depend_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -weld_timeout=`cat ../../cfg/config.cfg | grep "zone_build_weld_timeout" | sed -e 's/zone_build_weld_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the quality option to choose the goor properties.cfg file -quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` - -# **** Build dependencies - -if ( test "$quality_flag" ) -then - # We are in BEST mode - - # Log error - echo ------- >> log.log - echo --- Build zone : dependencies >> log.log - echo ------- >> log.log - echo ------- - echo --- Build zone : dependencies - echo ------- - date >> log.log - date - - cp ../../cfg/properties.cfg zone_depencies_properties.cfg - #append the level design directory at the end of the config file - ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` - echo "level_design_directory = \"$ld_dir\";" >> zone_depencies_properties.cfg - echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_depencies_properties.cfg - echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_depencies_properties.cfg - echo "continent_name = \"$continent_file_name\";" >> zone_depencies_properties.cfg - - - # list all the dependencies regions - zone_regions=`cat ../../cfg/config.cfg | grep "zone_region" | sed -e 's/zone_region//' | sed -e 's/ //g' | sed -e 's/=//g'` - - # For each dependencies region - for i in $zone_regions ; do - # Extract the name - arg=`echo zone_exported/$zone_regions | sed -e 's&,&.zone zone_exported/&g'` - # Make the dependencies - $exec_timeout $depend_timeout $zone_dependencies zone_depencies_properties.cfg $arg.zone zone_depend/doomy.depend - - # Idle - ../../idle.bat - done -fi - -# **** Weld - -# Log error -echo ------- >> log.log -echo --- Build zone : weld >> log.log -echo ------- >> log.log -echo ------- -echo --- Build zone : weld -echo ------- -date >> log.log -date - -# List the zones to weld -list_zone=`ls -1 zone_exported/*.[zZ][oO][nN][eE]` - -# Build a zones list to weld -echo -- Build a list of file to weld -rm zone_to_weld.txt 2> /dev/null -for i in $list_zone ; do - dest=`echo $i | sed -e 's/zone_exported/zone_welded/g' | sed -e 's/.zone/.zonew/g'` - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - echo $i >> zone_to_weld.txt - rm $dest - fi - - # Idle - ../../idle.bat -done - -# Weld the zone -if (test -f zone_to_weld.txt) -then - list_zone=`cat zone_to_weld.txt` - for i in $list_zone ; do - echo -- Weld $i - echo -- Weld $i >> log.log - $exec_timeout $weld_timeout $zone_welder $i $dest - echo - - # Idle - ../../idle.bat - done -fi - -# Log error -echo ------- >> log.log -echo --- Build zone : weld zones without heightmap >> log.log -echo ------- >> log.log -echo ------- -echo --- Build zone : weld zones without heightmap -echo ------- -date >> log.log -date - -# List the zones to weld -list_zone=`ls -1 zone_exported/*.[zZ][oO][nN][eE][nN][hH]` - -# Build a zones list to weld -echo -- Build a list of file to weld -rm zone_to_weld.txt 2> /dev/null -for i in $list_zone ; do - dest=`echo $i | sed -e 's/zone_exported/zone_welded/g' | sed -e 's/.zonenh/.zonenhw/g'` - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - echo $i >> zone_to_weld.txt - rm $dest - fi - - # Idle - ../../idle.bat -done - -# Weld the zone -if (test -f zone_to_weld.txt) -then - list_zone=`cat zone_to_weld.txt` - for i in $list_zone ; do - echo -- Weld $i - echo -- Weld $i >> log.log - $exec_timeout $weld_timeout $zone_welder $i $dest - echo - - # Idle - ../../idle.bat - done -fi - -# Build a zones list to weld -rm zone_to_weld.txt 2> /dev/null +#!/bin/bash +rm log.log 2> /dev/null + +# Build zone + +zone_dependencies='zone_dependencies.exe' +zone_welder='zone_welder.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +depend_timeout=`cat ../../cfg/config.cfg | grep "zone_build_depend_timeout" | sed -e 's/zone_build_depend_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +weld_timeout=`cat ../../cfg/config.cfg | grep "zone_build_weld_timeout" | sed -e 's/zone_build_weld_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the quality option to choose the goor properties.cfg file +quality_flag=`cat ../../cfg/site.cfg | grep "build_quality" | grep "1"` + +# **** Build dependencies + +if ( test "$quality_flag" ) +then + # We are in BEST mode + + # Log error + echo ------- >> log.log + echo --- Build zone : dependencies >> log.log + echo ------- >> log.log + echo ------- + echo --- Build zone : dependencies + echo ------- + date >> log.log + date + + cp ../../cfg/properties.cfg zone_depencies_properties.cfg + #append the level design directory at the end of the config file + ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` + echo "level_design_directory = \"$ld_dir\";" >> zone_depencies_properties.cfg + echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_depencies_properties.cfg + echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_depencies_properties.cfg + echo "continent_name = \"$continent_file_name\";" >> zone_depencies_properties.cfg + + + # list all the dependencies regions + zone_regions=`cat ../../cfg/config.cfg | grep "zone_region" | sed -e 's/zone_region//' | sed -e 's/ //g' | sed -e 's/=//g'` + + # For each dependencies region + for i in $zone_regions ; do + # Extract the name + arg=`echo zone_exported/$zone_regions | sed -e 's&,&.zone zone_exported/&g'` + # Make the dependencies + $exec_timeout $depend_timeout $zone_dependencies zone_depencies_properties.cfg $arg.zone zone_depend/doomy.depend + + # Idle + ../../idle.bat + done +fi + +# **** Weld + +# Log error +echo ------- >> log.log +echo --- Build zone : weld >> log.log +echo ------- >> log.log +echo ------- +echo --- Build zone : weld +echo ------- +date >> log.log +date + +# List the zones to weld +list_zone=`ls -1 zone_exported/*.[zZ][oO][nN][eE]` + +# Build a zones list to weld +echo -- Build a list of file to weld +rm zone_to_weld.txt 2> /dev/null +for i in $list_zone ; do + dest=`echo $i | sed -e 's/zone_exported/zone_welded/g' | sed -e 's/.zone/.zonew/g'` + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + echo $i >> zone_to_weld.txt + rm $dest + fi + + # Idle + ../../idle.bat +done + +# Weld the zone +if (test -f zone_to_weld.txt) +then + list_zone=`cat zone_to_weld.txt` + for i in $list_zone ; do + echo -- Weld $i + echo -- Weld $i >> log.log + $exec_timeout $weld_timeout $zone_welder $i $dest + echo + + # Idle + ../../idle.bat + done +fi + +# Log error +echo ------- >> log.log +echo --- Build zone : weld zones without heightmap >> log.log +echo ------- >> log.log +echo ------- +echo --- Build zone : weld zones without heightmap +echo ------- +date >> log.log +date + +# List the zones to weld +list_zone=`ls -1 zone_exported/*.[zZ][oO][nN][eE][nN][hH]` + +# Build a zones list to weld +echo -- Build a list of file to weld +rm zone_to_weld.txt 2> /dev/null +for i in $list_zone ; do + dest=`echo $i | sed -e 's/zone_exported/zone_welded/g' | sed -e 's/.zonenh/.zonenhw/g'` + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + echo $i >> zone_to_weld.txt + rm $dest + fi + + # Idle + ../../idle.bat +done + +# Weld the zone +if (test -f zone_to_weld.txt) +then + list_zone=`cat zone_to_weld.txt` + for i in $list_zone ; do + echo -- Weld $i + echo -- Weld $i >> log.log + $exec_timeout $weld_timeout $zone_welder $i $dest + echo + + # Idle + ../../idle.bat + done +fi + +# Build a zones list to weld +rm zone_to_weld.txt 2> /dev/null diff --git a/nel/tools/3d/build_gamedata/processes/zone/sh/export.sh b/nel/tools/3d/build_gamedata/processes/zone/sh/export.sh index db0520766..642c7e085 100644 --- a/nel/tools/3d/build_gamedata/processes/zone/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/zone/sh/export.sh @@ -1,109 +1,109 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export zone files (.zone) from Max - -exec_timeout='exec_timeout.exe' - -# Get the timeout -timeout=`cat ../../cfg/config.cfg | grep "zone_export_timeout" | sed -e 's/zone_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the build gamedata directory -build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the zone directories -zone_source_directories=`cat ../../cfg/directories.cfg | grep "zone_source_directory" | sed -e 's/zone_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the ligo value -ligo_flag=`cat ../../cfg/config.cfg | grep "process_to_complete" | grep "ligo"` - -# Maxdir -max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` - -if ( test "$ligo_flag" ) -then - echo [Ligo] ON - echo [Ligo] ON >> log.log -else - echo [Ligo] OFF - echo [Ligo] OFF >> log.log -fi - - -# Log error -echo ------- > log.log -echo --- Export zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Export zone -echo ------- -date >> log.log -date - -# Try to export from Max zone if any - -for i in $zone_source_directories ; do - # Copy the script - cat maxscript/zone_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/zone/log.log&g" | sed -e "s&zone_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/zone/zone_exported&g" > $max_directory/scripts/zone_export.ms - - # Start max - echo Try 1 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn - - echo Try 2 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn - - echo Try 3 >> log.log - $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn - - # Idle - ../../idle.bat -done - -# **************************** -# Try to copy ligo zone if any -# **************************** - -dir_current=`pwd` -cd ../ligo/output -list_zone=`ls -1 *.[zZ][oO][nN][eE]` -for filename in $list_zone ; do - echo "Checking $filename for update" - if test -e ../../zone/zone_exported/$filename ; then - must_update=`diff --binary -q $filename ../../zone/zone_exported/$filename` ; - else - must_update=YES ; - fi - - if test -n "$must_update" ; then - echo " Updating" - cp -u -p $filename ../../zone/zone_exported/$filename ; - fi - - # Idle - ../../../idle.bat -done -cd $dir_current - -# delete files only present in the zone_exported directory - -if ( test "$ligo_flag" ) -then - cd ./zone_exported - list_zone=`ls -1 *.[zZ][oO][nN][eE]` - for filename in $list_zone ; do - if test -e ../../ligo/output/$filename ; then - must_update=NO ; - else - echo "Removing $filename" - rm $filename ; - fi - - # Idle - ../../../idle.bat - done - cd .. -fi +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export zone files (.zone) from Max + +exec_timeout='exec_timeout.exe' + +# Get the timeout +timeout=`cat ../../cfg/config.cfg | grep "zone_export_timeout" | sed -e 's/zone_export_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the build gamedata directory +build_gamedata_directory=`cat ../../cfg/site.cfg | grep "build_gamedata_directory" | sed -e 's/build_gamedata_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the zone directories +zone_source_directories=`cat ../../cfg/directories.cfg | grep "zone_source_directory" | sed -e 's/zone_source_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the ligo value +ligo_flag=`cat ../../cfg/config.cfg | grep "process_to_complete" | grep "ligo"` + +# Maxdir +max_directory=`echo $MAX_DIR | sed -e 's&\\\&/&g'` + +if ( test "$ligo_flag" ) +then + echo [Ligo] ON + echo [Ligo] ON >> log.log +else + echo [Ligo] OFF + echo [Ligo] OFF >> log.log +fi + + +# Log error +echo ------- > log.log +echo --- Export zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Export zone +echo ------- +date >> log.log +date + +# Try to export from Max zone if any + +for i in $zone_source_directories ; do + # Copy the script + cat maxscript/zone_export.ms | sed -e "s&output_logfile&$build_gamedata_directory/processes/zone/log.log&g" | sed -e "s&zone_source_directory&$database_directory/$i&g" | sed -e "s&output_directory&$build_gamedata_directory/processes/zone/zone_exported&g" > $max_directory/scripts/zone_export.ms + + # Start max + echo Try 1 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn + + echo Try 2 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn + + echo Try 3 >> log.log + $exec_timeout $timeout $max_directory/3dsmax.exe -U MAXScript zone_export.ms -q -mi -vn + + # Idle + ../../idle.bat +done + +# **************************** +# Try to copy ligo zone if any +# **************************** + +dir_current=`pwd` +cd ../ligo/output +list_zone=`ls -1 *.[zZ][oO][nN][eE]` +for filename in $list_zone ; do + echo "Checking $filename for update" + if test -e ../../zone/zone_exported/$filename ; then + must_update=`diff --binary -q $filename ../../zone/zone_exported/$filename` ; + else + must_update=YES ; + fi + + if test -n "$must_update" ; then + echo " Updating" + cp -u -p $filename ../../zone/zone_exported/$filename ; + fi + + # Idle + ../../../idle.bat +done +cd $dir_current + +# delete files only present in the zone_exported directory + +if ( test "$ligo_flag" ) +then + cd ./zone_exported + list_zone=`ls -1 *.[zZ][oO][nN][eE]` + for filename in $list_zone ; do + if test -e ../../ligo/output/$filename ; then + must_update=NO ; + else + echo "Removing $filename" + rm $filename ; + fi + + # Idle + ../../../idle.bat + done + cd .. +fi diff --git a/nel/tools/3d/build_gamedata/processes/zone_light/sh/build.sh b/nel/tools/3d/build_gamedata/processes/zone_light/sh/build.sh index 446baca98..34645f295 100644 --- a/nel/tools/3d/build_gamedata/processes/zone_light/sh/build.sh +++ b/nel/tools/3d/build_gamedata/processes/zone_light/sh/build.sh @@ -1,119 +1,119 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build zone - -zone_lighter='zone_lighter.exe' -zone_ig_lighter='zone_ig_lighter.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_light_timeout" | sed -e 's/zone_build_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -ig_light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_ig_light_timeout" | sed -e 's/zone_build_ig_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# **** Light - -# Log error -echo ------- >> log.log -echo --- Zone lighting >> log.log -echo ------- >> log.log -echo ------- -echo --- Zone lighting -echo ------- -date >> log.log -date - -#append the level design directory at the end of the config file -ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` -cp ../../cfg/properties.cfg zone_lighter_properties.cfg -echo "level_design_directory = \"$ld_dir\";" >> zone_lighter_properties.cfg -echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_lighter_properties.cfg -echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_lighter_properties.cfg -echo "continent_name = \"$continent_file_name\";" >> zone_lighter_properties.cfg - -# List the zones to light -list_zone_welded=`ls -1 ../zone/zone_welded/*.[zZ][oO][nN][eE][wW]` - -# Light zones -for i in $list_zone_welded ; do - dest=`echo $i | sed -e 's&../zone/zone_welded&zone_lighted&g' | sed -e 's/.zonew/.zonel/g'` - depend=`echo $i | sed -e 's&../zone/zone_welded&../zone/zone_depend&g' | sed -e 's/.zonew/.depend/g'` - if ( ! test -e $dest ) || ( test $i -nt $dest ) - then - echo LIGHT $i - echo LIGHT $i >> log.log - $exec_timeout $light_timeout $zone_lighter $i $dest zone_lighter_properties.cfg $depend - echo - echo - else - echo SKIP $dest - echo SKIP $dest >> log.log - fi - - # Idle - ../../idle.bat -done - -# List the zones lighted -list_zone_lighted_remove=`ls -1 zone_lighted/*.[zZ][oO][nN][eE][lL]` - -# Remove old lighted zones -for i in $list_zone_lighted_remove ; do - source=`echo $i | sed -e 's&zone_lighted&../zone/zone_welded&g' | sed -e 's/.zonel/.zonew/g'` - if ( ! test -e $source ) - then - echo REMOVE $i - echo REMOVE $i >> log.log - rm $i - fi - - # Idle - ../../idle.bat -done - - -# **** IgLight - -# Log error -echo ------- >> log.log -echo --- Build zone : IgLight >> log.log -echo ------- >> log.log -echo ------- -echo --- Build zone : IgLight -echo ------- -date >> log.log -date - -# List the zones lighted -list_zone_lighted=`ls -1 zone_lighted/*.[zZ][oO][nN][eE][lL]` - -# Light zones -for i in $list_zone_lighted ; do - dest=`echo $i | sed -e 's/zone_lighted/ig_land_lighted/g' | sed -e 's/.zonel/.ig/g'` - depend=`echo $i | sed -e 's&zone_lighted&../zone/zone_depend&g' | sed -e 's/.zonel/.depend/g'` - igsrc=`echo $i | sed -e 's&zone_lighted&../ig/ig_land&g' | sed -e 's/.zonel/.ig/g'` - if ( test -f $igsrc ) - then - if ( ! test -e $dest ) || ( test $i -nt $dest ) || ( test $igsrc -nt $dest ) - then - echo -- IgLight $i - echo -- IgLight $i >> log.log - $exec_timeout $ig_light_timeout $zone_ig_lighter $i $dest ../../cfg/properties.cfg $depend - echo - echo - fi - else - if ( test -f $dest ) - then - echo "-- Remove" $dest - rm $dest - fi - fi - - # Idle - ../../idle.bat -done - +#!/bin/bash +rm log.log 2> /dev/null + +# Build zone + +zone_lighter='zone_lighter.exe' +zone_ig_lighter='zone_ig_lighter.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_light_timeout" | sed -e 's/zone_build_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +ig_light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_ig_light_timeout" | sed -e 's/zone_build_ig_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# **** Light + +# Log error +echo ------- >> log.log +echo --- Zone lighting >> log.log +echo ------- >> log.log +echo ------- +echo --- Zone lighting +echo ------- +date >> log.log +date + +#append the level design directory at the end of the config file +ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` +cp ../../cfg/properties.cfg zone_lighter_properties.cfg +echo "level_design_directory = \"$ld_dir\";" >> zone_lighter_properties.cfg +echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_lighter_properties.cfg +echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_lighter_properties.cfg +echo "continent_name = \"$continent_file_name\";" >> zone_lighter_properties.cfg + +# List the zones to light +list_zone_welded=`ls -1 ../zone/zone_welded/*.[zZ][oO][nN][eE][wW]` + +# Light zones +for i in $list_zone_welded ; do + dest=`echo $i | sed -e 's&../zone/zone_welded&zone_lighted&g' | sed -e 's/.zonew/.zonel/g'` + depend=`echo $i | sed -e 's&../zone/zone_welded&../zone/zone_depend&g' | sed -e 's/.zonew/.depend/g'` + if ( ! test -e $dest ) || ( test $i -nt $dest ) + then + echo LIGHT $i + echo LIGHT $i >> log.log + $exec_timeout $light_timeout $zone_lighter $i $dest zone_lighter_properties.cfg $depend + echo + echo + else + echo SKIP $dest + echo SKIP $dest >> log.log + fi + + # Idle + ../../idle.bat +done + +# List the zones lighted +list_zone_lighted_remove=`ls -1 zone_lighted/*.[zZ][oO][nN][eE][lL]` + +# Remove old lighted zones +for i in $list_zone_lighted_remove ; do + source=`echo $i | sed -e 's&zone_lighted&../zone/zone_welded&g' | sed -e 's/.zonel/.zonew/g'` + if ( ! test -e $source ) + then + echo REMOVE $i + echo REMOVE $i >> log.log + rm $i + fi + + # Idle + ../../idle.bat +done + + +# **** IgLight + +# Log error +echo ------- >> log.log +echo --- Build zone : IgLight >> log.log +echo ------- >> log.log +echo ------- +echo --- Build zone : IgLight +echo ------- +date >> log.log +date + +# List the zones lighted +list_zone_lighted=`ls -1 zone_lighted/*.[zZ][oO][nN][eE][lL]` + +# Light zones +for i in $list_zone_lighted ; do + dest=`echo $i | sed -e 's/zone_lighted/ig_land_lighted/g' | sed -e 's/.zonel/.ig/g'` + depend=`echo $i | sed -e 's&zone_lighted&../zone/zone_depend&g' | sed -e 's/.zonel/.depend/g'` + igsrc=`echo $i | sed -e 's&zone_lighted&../ig/ig_land&g' | sed -e 's/.zonel/.ig/g'` + if ( test -f $igsrc ) + then + if ( ! test -e $dest ) || ( test $i -nt $dest ) || ( test $igsrc -nt $dest ) + then + echo -- IgLight $i + echo -- IgLight $i >> log.log + $exec_timeout $ig_light_timeout $zone_ig_lighter $i $dest ../../cfg/properties.cfg $depend + echo + echo + fi + else + if ( test -f $dest ) + then + echo "-- Remove" $dest + rm $dest + fi + fi + + # Idle + ../../idle.bat +done + diff --git a/nel/tools/3d/build_gamedata/processes/zone_light/sh/export.sh b/nel/tools/3d/build_gamedata/processes/zone_light/sh/export.sh index 26f4225ef..29cb5a57f 100644 --- a/nel/tools/3d/build_gamedata/processes/zone_light/sh/export.sh +++ b/nel/tools/3d/build_gamedata/processes/zone_light/sh/export.sh @@ -1,28 +1,28 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# *** Export zone files (.zone) from Max - -# Get the database directory -database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the water maps directories -water_map_directories=`cat ../../cfg/directories.cfg | grep "water_map_directory" | sed -e 's/water_map_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Export water shape >> log.log -echo ------- >> log.log -echo ------- -echo --- Export water shape -echo ------- -date >> log.log -date - -#copy each water map before lightmapping -for i in $water_map_directories ; do - cp -u -p $database_directory/$i/*.[tT][gG][aA] water_shapes_lighted 2>> log.log - - # Idle - ../../idle.bat -done +#!/bin/bash +rm log.log 2> /dev/null + +# *** Export zone files (.zone) from Max + +# Get the database directory +database_directory=`cat ../../cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the water maps directories +water_map_directories=`cat ../../cfg/directories.cfg | grep "water_map_directory" | sed -e 's/water_map_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Export water shape >> log.log +echo ------- >> log.log +echo ------- +echo --- Export water shape +echo ------- +date >> log.log +date + +#copy each water map before lightmapping +for i in $water_map_directories ; do + cp -u -p $database_directory/$i/*.[tT][gG][aA] water_shapes_lighted 2>> log.log + + # Idle + ../../idle.bat +done diff --git a/nel/tools/3d/build_gamedata/processes/zone_light/sh/install.sh b/nel/tools/3d/build_gamedata/processes/zone_light/sh/install.sh index c5ddb8831..abfa1ab1d 100644 --- a/nel/tools/3d/build_gamedata/processes/zone_light/sh/install.sh +++ b/nel/tools/3d/build_gamedata/processes/zone_light/sh/install.sh @@ -1,44 +1,44 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the zonels in the client data - -# Get the zone install directory -zone_install_directory=`cat ../../cfg/directories.cfg | grep "zone_install_directory" | sed -e 's/zone_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client directory -client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install zone >> log.log -echo ------- >> log.log -echo ------- -echo --- Install zone -echo ------- -date >> log.log -date - -cp -u -p -R zone_lighted/. $client_directory/$zone_install_directory 2>> log.log - -# copy the water maps once they have been lighted -cp -u -p -R water_shapes_lighted/. $client_directory/$water_maps_directories - - - -# Install zone ig lighted in the client data - -# Get the ig install directory -ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo ------- > log.log -echo --- Install Zone Ig >> log.log -echo ------- >> log.log -echo ------- -echo --- Install Zone Ig -echo ------- -date >> log.log -date - -cp -u -p -R ig_land_lighted/. $client_directory/$ig_install_directory 2>> log.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the zonels in the client data + +# Get the zone install directory +zone_install_directory=`cat ../../cfg/directories.cfg | grep "zone_install_directory" | sed -e 's/zone_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client directory +client_directory=`cat ../../cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install zone >> log.log +echo ------- >> log.log +echo ------- +echo --- Install zone +echo ------- +date >> log.log +date + +cp -u -p -R zone_lighted/. $client_directory/$zone_install_directory 2>> log.log + +# copy the water maps once they have been lighted +cp -u -p -R water_shapes_lighted/. $client_directory/$water_maps_directories + + + +# Install zone ig lighted in the client data + +# Get the ig install directory +ig_install_directory=`cat ../../cfg/directories.cfg | grep "ig_install_directory" | sed -e 's/ig_install_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo ------- > log.log +echo --- Install Zone Ig >> log.log +echo ------- >> log.log +echo ------- +echo --- Install Zone Ig +echo ------- +date >> log.log +date + +cp -u -p -R ig_land_lighted/. $client_directory/$ig_install_directory 2>> log.log diff --git a/nel/tools/3d/build_gamedata/processes/zone_light/sh/patch_tile_water.sh b/nel/tools/3d/build_gamedata/processes/zone_light/sh/patch_tile_water.sh index 205a4048d..87ebd9eac 100644 --- a/nel/tools/3d/build_gamedata/processes/zone_light/sh/patch_tile_water.sh +++ b/nel/tools/3d/build_gamedata/processes/zone_light/sh/patch_tile_water.sh @@ -1,63 +1,63 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build zone - -zone_lighter='zone_lighter.exe' -zone_ig_lighter='zone_ig_lighter.exe' -exec_timeout='exec_timeout.exe' - -# Get the timeout -light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_light_timeout" | sed -e 's/zone_build_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` -ig_light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_ig_light_timeout" | sed -e 's/zone_build_ig_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# **** Light - -# Log error -echo ------- >> log.log -echo --- Zone lighting >> log.log -echo ------- >> log.log -echo ------- -echo --- Zone lighting -echo ------- -date >> log.log -date - -#append the level design directory at the end of the config file -ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` -continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` -cp ../../cfg/properties.cfg zone_lighter_properties.cfg -echo "level_design_directory = \"$ld_dir\";" >> zone_lighter_properties.cfg -echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_lighter_properties.cfg -echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_lighter_properties.cfg -echo "continent_name = \"$continent_file_name\";" >> zone_lighter_properties.cfg - -# List the zones to light -list_zone_welded=`ls -1 ../zone/zone_welded/*.[zZ][oO][nN][eE][wW]` - -# create a bkup directory -mkdir bkup_tile_water - -# Light zones -for i in $list_zone_welded ; do - dest=`echo $i | sed -e 's&../zone/zone_welded&zone_lighted&g' | sed -e 's/.zonew/.zonel/g'` - depend=`echo $i | sed -e 's&../zone/zone_welded&../zone/zone_depend&g' | sed -e 's/.zonew/.depend/g'` - if ( test -e $dest ) - then - echo PATCH $dest - echo PATCH $dest >> log.log - # patch, and bkup if necessary - $exec_timeout $light_timeout $zone_lighter $i $dest zone_lighter_properties.cfg $depend -waterpatch bkup_tile_water - echo - echo - else - echo SKIP $dest cause not found - echo SKIP $dest cause not found >> log.log - fi - - # Idle - ../../idle.bat -done - +#!/bin/bash +rm log.log 2> /dev/null + +# Build zone + +zone_lighter='zone_lighter.exe' +zone_ig_lighter='zone_ig_lighter.exe' +exec_timeout='exec_timeout.exe' + +# Get the timeout +light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_light_timeout" | sed -e 's/zone_build_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` +ig_light_timeout=`cat ../../cfg/config.cfg | grep "zone_build_ig_light_timeout" | sed -e 's/zone_build_ig_light_timeout//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# **** Light + +# Log error +echo ------- >> log.log +echo --- Zone lighting >> log.log +echo ------- >> log.log +echo ------- +echo --- Zone lighting +echo ------- +date >> log.log +date + +#append the level design directory at the end of the config file +ld_dir=`cat ../../cfg/site.cfg | grep "level_design_directory" | sed -e 's/level_design_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +ld_world_dir=`cat ../../cfg/site.cfg | grep "level_design_world_directory" | sed -e 's/level_design_world_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +ld_dfn_dir=`cat ../../cfg/site.cfg | grep "level_design_dfn_directory" | sed -e 's/level_design_dfn_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` +continent_file_name=`cat ../../cfg/config.cfg | grep "continent_file" | sed -e 's/continent_file//g' | sed -e 's/ //g' | sed -e 's/=//g'` +cp ../../cfg/properties.cfg zone_lighter_properties.cfg +echo "level_design_directory = \"$ld_dir\";" >> zone_lighter_properties.cfg +echo "level_design_world_directory = \"$ld_world_dir\";" >> zone_lighter_properties.cfg +echo "level_design_dfn_directory = \"$ld_dfn_dir\";" >> zone_lighter_properties.cfg +echo "continent_name = \"$continent_file_name\";" >> zone_lighter_properties.cfg + +# List the zones to light +list_zone_welded=`ls -1 ../zone/zone_welded/*.[zZ][oO][nN][eE][wW]` + +# create a bkup directory +mkdir bkup_tile_water + +# Light zones +for i in $list_zone_welded ; do + dest=`echo $i | sed -e 's&../zone/zone_welded&zone_lighted&g' | sed -e 's/.zonew/.zonel/g'` + depend=`echo $i | sed -e 's&../zone/zone_welded&../zone/zone_depend&g' | sed -e 's/.zonew/.depend/g'` + if ( test -e $dest ) + then + echo PATCH $dest + echo PATCH $dest >> log.log + # patch, and bkup if necessary + $exec_timeout $light_timeout $zone_lighter $i $dest zone_lighter_properties.cfg $depend -waterpatch bkup_tile_water + echo + echo + else + echo SKIP $dest cause not found + echo SKIP $dest cause not found >> log.log + fi + + # Idle + ../../idle.bat +done + diff --git a/nel/tools/3d/build_gamedata/sh/build.sh b/nel/tools/3d/build_gamedata/sh/build.sh index 00787e5b4..cfbd89fd5 100644 --- a/nel/tools/3d/build_gamedata/sh/build.sh +++ b/nel/tools/3d/build_gamedata/sh/build.sh @@ -1,33 +1,33 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Build the processes - -# Get the process list -process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Log error -echo > log.log -date >> log.log -date - -# For each process -for i in $process_to_complete ; do - # Open the directory - cd processes/$i - - # Excecute the command - ./3_build.bat - - # Get back - cd ../.. - - # Concat log.log files - cat processes/$i/log.log >> log.log - - # Idle - ./idle.bat -done - -# Copy the log file -cp log.log build.log +#!/bin/bash +rm log.log 2> /dev/null + +# Build the processes + +# Get the process list +process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Log error +echo > log.log +date >> log.log +date + +# For each process +for i in $process_to_complete ; do + # Open the directory + cd processes/$i + + # Excecute the command + ./3_build.bat + + # Get back + cd ../.. + + # Concat log.log files + cat processes/$i/log.log >> log.log + + # Idle + ./idle.bat +done + +# Copy the log file +cp log.log build.log diff --git a/nel/tools/3d/build_gamedata/sh/clean.sh b/nel/tools/3d/build_gamedata/sh/clean.sh index ab2ef5800..b2ece6d87 100644 --- a/nel/tools/3d/build_gamedata/sh/clean.sh +++ b/nel/tools/3d/build_gamedata/sh/clean.sh @@ -1,29 +1,29 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Clean the processes - -# Get the process list -process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Log error -echo > log.log - -# For each process -for i in $process_to_complete ; do - # Open the directory - cd processes/$i - - # Excecute the command - ./1_clean.bat - - # Get back - cd ../.. - - # Concat log.log files - # cat processes/$i/log.log >> log.log - - # Idle - ./idle.bat -done - +#!/bin/bash +rm log.log 2> /dev/null + +# Clean the processes + +# Get the process list +process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Log error +echo > log.log + +# For each process +for i in $process_to_complete ; do + # Open the directory + cd processes/$i + + # Excecute the command + ./1_clean.bat + + # Get back + cd ../.. + + # Concat log.log files + # cat processes/$i/log.log >> log.log + + # Idle + ./idle.bat +done + diff --git a/nel/tools/3d/build_gamedata/sh/client_clean.sh b/nel/tools/3d/build_gamedata/sh/client_clean.sh index 08c9d97b8..2ec474fa2 100644 --- a/nel/tools/3d/build_gamedata/sh/client_clean.sh +++ b/nel/tools/3d/build_gamedata/sh/client_clean.sh @@ -1,27 +1,27 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Clean the client - -# Get the client directory -client_directory=`cat cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client setup directories -client_setup_directories=`cat cfg/directories.cfg | grep "client_setup_directory" | sed -e 's/client_setup_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* > log.log -echo \*\*\*\*\*\*\* CLIENT CLEAN>> log.log -echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* >> log.log -echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* -echo \*\*\*\*\*\*\* CLIENT CLEAN -echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* - -# For each directory -for i in $client_setup_directories ; do - # Create the directory - rm $client_directory/$i/* - - # Idle - ./idle.bat +#!/bin/bash +rm log.log 2> /dev/null + +# Clean the client + +# Get the client directory +client_directory=`cat cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client setup directories +client_setup_directories=`cat cfg/directories.cfg | grep "client_setup_directory" | sed -e 's/client_setup_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* > log.log +echo \*\*\*\*\*\*\* CLIENT CLEAN>> log.log +echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* >> log.log +echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* +echo \*\*\*\*\*\*\* CLIENT CLEAN +echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* + +# For each directory +for i in $client_setup_directories ; do + # Create the directory + rm $client_directory/$i/* + + # Idle + ./idle.bat done \ No newline at end of file diff --git a/nel/tools/3d/build_gamedata/sh/client_setup.sh b/nel/tools/3d/build_gamedata/sh/client_setup.sh index 33cb1c2bf..f9c6f1688 100644 --- a/nel/tools/3d/build_gamedata/sh/client_setup.sh +++ b/nel/tools/3d/build_gamedata/sh/client_setup.sh @@ -1,24 +1,24 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Setup the client - -# Get the client directory -client_directory=`cat cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the client setup directories -client_setup_directories=`cat cfg/directories.cfg | grep "client_setup_directory" | sed -e 's/client_setup_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Log error -echo > log.log - -# Create the file - -# For each directory -for i in $client_setup_directories ; do - # Create the directory - mkdir $client_directory/$i 2> /dev/null - - # Idle - ./idle.bat +#!/bin/bash +rm log.log 2> /dev/null + +# Setup the client + +# Get the client directory +client_directory=`cat cfg/site.cfg | grep "client_directory" | sed -e 's/client_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the client setup directories +client_setup_directories=`cat cfg/directories.cfg | grep "client_setup_directory" | sed -e 's/client_setup_directory//' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Log error +echo > log.log + +# Create the file + +# For each directory +for i in $client_setup_directories ; do + # Create the directory + mkdir $client_directory/$i 2> /dev/null + + # Idle + ./idle.bat done \ No newline at end of file diff --git a/nel/tools/3d/build_gamedata/sh/export.sh b/nel/tools/3d/build_gamedata/sh/export.sh index 836a3bfe5..16a22a000 100644 --- a/nel/tools/3d/build_gamedata/sh/export.sh +++ b/nel/tools/3d/build_gamedata/sh/export.sh @@ -1,33 +1,33 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Export the processes - -# Get the process list -process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Log error -echo > log.log -date >> log.log -date - -# For each process -for i in $process_to_complete ; do - # Open the directory - cd processes/$i - - # Excecute the command - ./2_export.bat - - # Get back - cd ../.. - - # Concat log.log files - cat processes/$i/log.log >> log.log - - # Idle - ./idle.bat -done - -# Copy the log file -cp log.log export.log +#!/bin/bash +rm log.log 2> /dev/null + +# Export the processes + +# Get the process list +process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Log error +echo > log.log +date >> log.log +date + +# For each process +for i in $process_to_complete ; do + # Open the directory + cd processes/$i + + # Excecute the command + ./2_export.bat + + # Get back + cd ../.. + + # Concat log.log files + cat processes/$i/log.log >> log.log + + # Idle + ./idle.bat +done + +# Copy the log file +cp log.log export.log diff --git a/nel/tools/3d/build_gamedata/sh/install.sh b/nel/tools/3d/build_gamedata/sh/install.sh index 25b56685d..28d6c4803 100644 --- a/nel/tools/3d/build_gamedata/sh/install.sh +++ b/nel/tools/3d/build_gamedata/sh/install.sh @@ -1,33 +1,33 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Install the processes - -# Get the process list -process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Log error -echo > log.log -date >> log.log -date - -# For each process -for i in $process_to_complete ; do - # Open the directory - cd processes/$i - - # Excecute the command - ./4_install.bat - - # Get back - cd ../.. - - # Concat log.log files - cat processes/$i/log.log >> log.log - - # Idle - ./idle.bat -done - -# Copy the log file -cp log.log install.log +#!/bin/bash +rm log.log 2> /dev/null + +# Install the processes + +# Get the process list +process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Log error +echo > log.log +date >> log.log +date + +# For each process +for i in $process_to_complete ; do + # Open the directory + cd processes/$i + + # Excecute the command + ./4_install.bat + + # Get back + cd ../.. + + # Concat log.log files + cat processes/$i/log.log >> log.log + + # Idle + ./idle.bat +done + +# Copy the log file +cp log.log install.log diff --git a/nel/tools/3d/build_gamedata/sh/setup.sh b/nel/tools/3d/build_gamedata/sh/setup.sh index 8330c6cb8..6e83ca7b8 100644 --- a/nel/tools/3d/build_gamedata/sh/setup.sh +++ b/nel/tools/3d/build_gamedata/sh/setup.sh @@ -1,62 +1,62 @@ -#!/bin/bash -rm log.log 2> /dev/null - -# Setup the processes - -# Get the process list -process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Get the update directory -update_directory=`cat cfg/config.cfg | grep "update_directory" | sed -e 's/update_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` - -# Get the database directory -database_directory=`cat cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database letter -database_letter=`cat cfg/site.cfg | grep "database_letter" | sed -e 's/database_letter//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -# Get the database server -database_server=`cat cfg/site.cfg | grep "database_server" | sed -e 's/database_server//g' | sed -e 's/ //g' | sed -e 's/=//g'` - -`cat _idle.bat | sed -e "s&database_directory&$database_directory&g" | sed -e "s&database_letter&$database_letter&g" | sed -e "s&database_server&$database_server&g" > idle.bat` - -# Log error -echo > log.log -date >> log.log -date - -# Create a bin dir -mkdir bin 2> /dev/null - -# For each process -for i in $process_to_complete ; do - # Open the directory - cd processes/$i - - # Excecute the command - ./0_setup.bat - - # Get back - cd ../.. - - # Concat log.log files - # cat processes/$i/log.log >> log.log - - # Idle - ./idle.bat -done - -# Get the quality option to choose the goor properties.cfg file -quality_flag=`cat cfg/site.cfg | grep "build_quality" | grep "1"` - -# Copy the good properties.cfg file -if ( test "$quality_flag" ) -then - # We are in BEST mode - echo [Quality] BEST - cp cfg/properties_final.cfg cfg/properties.cfg -else - # We are not DRAFT mode - echo [Quality] DRAFT - cp cfg/properties_draft.cfg cfg/properties.cfg -fi +#!/bin/bash +rm log.log 2> /dev/null + +# Setup the processes + +# Get the process list +process_to_complete=`cat cfg/config.cfg | grep "process_to_complete" | sed -e 's/process_to_complete//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Get the update directory +update_directory=`cat cfg/config.cfg | grep "update_directory" | sed -e 's/update_directory//' | sed -e 's/ //g' | sed -e 's/=//g' | sed -e 's/,/ /g'` + +# Get the database directory +database_directory=`cat cfg/site.cfg | grep "database_directory" | sed -e 's/database_directory//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database letter +database_letter=`cat cfg/site.cfg | grep "database_letter" | sed -e 's/database_letter//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +# Get the database server +database_server=`cat cfg/site.cfg | grep "database_server" | sed -e 's/database_server//g' | sed -e 's/ //g' | sed -e 's/=//g'` + +`cat _idle.bat | sed -e "s&database_directory&$database_directory&g" | sed -e "s&database_letter&$database_letter&g" | sed -e "s&database_server&$database_server&g" > idle.bat` + +# Log error +echo > log.log +date >> log.log +date + +# Create a bin dir +mkdir bin 2> /dev/null + +# For each process +for i in $process_to_complete ; do + # Open the directory + cd processes/$i + + # Excecute the command + ./0_setup.bat + + # Get back + cd ../.. + + # Concat log.log files + # cat processes/$i/log.log >> log.log + + # Idle + ./idle.bat +done + +# Get the quality option to choose the goor properties.cfg file +quality_flag=`cat cfg/site.cfg | grep "build_quality" | grep "1"` + +# Copy the good properties.cfg file +if ( test "$quality_flag" ) +then + # We are in BEST mode + echo [Quality] BEST + cp cfg/properties_final.cfg cfg/properties.cfg +else + # We are not DRAFT mode + echo [Quality] DRAFT + cp cfg/properties_draft.cfg cfg/properties.cfg +fi diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/libapi/libapi.c b/ryzom/client/src/lua_ide_dll_nevrax/source/libapi/libapi.c index ddc5c620e..5f2a007d4 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/libapi/libapi.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/libapi/libapi.c @@ -1,147 +1,147 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdafx.h" - -#include "../ide2/DebuggerMessages.h" - -static HWND g_hWnd; - -using namespace std; - -// maximum mumber of lines the output console should have -static const WORD MAX_CONSOLE_LINES = 500; - -BOOL isWindowsNT(void) -{ - static BOOL once = FALSE; - static BOOL isNT = FALSE; - - if (!once) - { - OSVERSIONINFO osver; - osver.dwOSVersionInfoSize = sizeof(osver); - if (GetVersionEx(&osver)) - if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) - isNT = TRUE; - once = TRUE; - } - return isNT; -} - -static BOOL CALLBACK EnumttyWindow(HWND wnd, LPARAM retwnd) -{ - char tmp[20], *tty; - if (isWindowsNT()) - tty = "ConsoleWindowClass"; - else - tty = "tty"; - if (GetClassName(wnd, tmp, sizeof(tmp)) && !strcmp(tmp, tty)) - { - DWORD wndproc, thisproc = GetCurrentProcessId(); - GetWindowThreadProcessId(wnd, &wndproc); - if (wndproc == thisproc) { - *((HWND*)retwnd) = wnd; - return FALSE; - } - } - return TRUE; -} - - -static BOOL CtrlHandler(DWORD fdwCtrlType) -{ - switch (fdwCtrlType) - { - // Handle the CTRL+C signal. - - case CTRL_C_EVENT: - case CTRL_BREAK_EVENT: - return TRUE; - - // CTRL+CLOSE: confirm that the user wants to exit. - - case CTRL_CLOSE_EVENT: - - case CTRL_LOGOFF_EVENT: - - case CTRL_SHUTDOWN_EVENT: - - default: - - return FALSE; - } -} - -void AttachConsole() -{ - int hConHandle; - long lStdHandle; - CONSOLE_SCREEN_BUFFER_INFO coninfo; - FILE *fp; - HWND hWndConsole; - HMENU hSysMenu; - -// allocate a console for this app - FreeConsole(); - AllocConsole(); - -//disable system menu -> close box - EnumWindows(EnumttyWindow, (long)(&hWndConsole)); - hSysMenu = GetSystemMenu(hWndConsole, FALSE); - ModifyMenu(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED, 0, 0); - ShowWindow(hWndConsole, SW_SHOW); - -// set the screen buffer to be big enough to let us scroll text - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); - coninfo.dwSize.Y = MAX_CONSOLE_LINES; - SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); - -// redirect unbuffered STDOUT to the console - lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - fp = _fdopen( hConHandle, "w" ); - *stdout = *fp; - setvbuf( stdout, NULL, _IONBF, 0 ); - -// redirect unbuffered STDIN to the console - lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - ::SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_MOUSE_INPUT); - fp = _fdopen( hConHandle, "r" ); - *stdin = *fp; - setvbuf( stdin, NULL, _IONBF, 0 ); - -// redirect unbuffered STDERR to the console - lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); - hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - fp = _fdopen( hConHandle, "w" ); - *stderr = *fp; - setvbuf( stderr, NULL, _IONBF, 0 ); - -// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog -// point to console as well - ios::sync_with_stdio(); - - SetConsoleCtrlHandler( - (PHANDLER_ROUTINE) CtrlHandler, // handler function - TRUE); // add to list -} - -BOOL InitLibAPI(HWND hWnd) -{ - g_hWnd = hWnd; -} +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdafx.h" + +#include "../ide2/DebuggerMessages.h" + +static HWND g_hWnd; + +using namespace std; + +// maximum mumber of lines the output console should have +static const WORD MAX_CONSOLE_LINES = 500; + +BOOL isWindowsNT(void) +{ + static BOOL once = FALSE; + static BOOL isNT = FALSE; + + if (!once) + { + OSVERSIONINFO osver; + osver.dwOSVersionInfoSize = sizeof(osver); + if (GetVersionEx(&osver)) + if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) + isNT = TRUE; + once = TRUE; + } + return isNT; +} + +static BOOL CALLBACK EnumttyWindow(HWND wnd, LPARAM retwnd) +{ + char tmp[20], *tty; + if (isWindowsNT()) + tty = "ConsoleWindowClass"; + else + tty = "tty"; + if (GetClassName(wnd, tmp, sizeof(tmp)) && !strcmp(tmp, tty)) + { + DWORD wndproc, thisproc = GetCurrentProcessId(); + GetWindowThreadProcessId(wnd, &wndproc); + if (wndproc == thisproc) { + *((HWND*)retwnd) = wnd; + return FALSE; + } + } + return TRUE; +} + + +static BOOL CtrlHandler(DWORD fdwCtrlType) +{ + switch (fdwCtrlType) + { + // Handle the CTRL+C signal. + + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + return TRUE; + + // CTRL+CLOSE: confirm that the user wants to exit. + + case CTRL_CLOSE_EVENT: + + case CTRL_LOGOFF_EVENT: + + case CTRL_SHUTDOWN_EVENT: + + default: + + return FALSE; + } +} + +void AttachConsole() +{ + int hConHandle; + long lStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + FILE *fp; + HWND hWndConsole; + HMENU hSysMenu; + +// allocate a console for this app + FreeConsole(); + AllocConsole(); + +//disable system menu -> close box + EnumWindows(EnumttyWindow, (long)(&hWndConsole)); + hSysMenu = GetSystemMenu(hWndConsole, FALSE); + ModifyMenu(hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED, 0, 0); + ShowWindow(hWndConsole, SW_SHOW); + +// set the screen buffer to be big enough to let us scroll text + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); + coninfo.dwSize.Y = MAX_CONSOLE_LINES; + SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); + +// redirect unbuffered STDOUT to the console + lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + +// redirect unbuffered STDIN to the console + lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + ::SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_MOUSE_INPUT); + fp = _fdopen( hConHandle, "r" ); + *stdin = *fp; + setvbuf( stdin, NULL, _IONBF, 0 ); + +// redirect unbuffered STDERR to the console + lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stderr = *fp; + setvbuf( stderr, NULL, _IONBF, 0 ); + +// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog +// point to console as well + ios::sync_with_stdio(); + + SetConsoleCtrlHandler( + (PHANDLER_ROUTINE) CtrlHandler, // handler function + TRUE); // add to list +} + +BOOL InitLibAPI(HWND hWnd) +{ + g_hWnd = hWnd; +} diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lauxlib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lauxlib.c index adc01cb89..1ef987735 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lauxlib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lauxlib.c @@ -1,601 +1,601 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include - - -/* This file uses only the official API of Lua. -** Any function declared here could be written as an application function. -*/ - -#define lauxlib_c - -#include "lua.h" - -#include "lauxlib.h" - - -/* number of prereserved references (for internal use) */ -#define RESERVED_REFS 2 - -/* reserved references */ -#define FREELIST_REF 1 /* free list of references */ -#define ARRAYSIZE_REF 2 /* array sizes */ - - -/* convert a stack index to positive */ -#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ - lua_gettop(L) + (i) + 1) - - -/* -** {====================================================== -** Error-report functions -** ======================================================= -*/ - - -LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { - lua_Debug ar; - lua_getstack(L, 0, &ar); - lua_getinfo(L, "n", &ar); - if (strcmp(ar.namewhat, "method") == 0) { - narg--; /* do not count `self' */ - if (narg == 0) /* error is in the self argument itself? */ - return luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg); - } - if (ar.name == NULL) - ar.name = "?"; - return luaL_error(L, "bad argument #%d to `%s' (%s)", - narg, ar.name, extramsg); -} - - -LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { - const char *msg = lua_pushfstring(L, "%s expected, got %s", - tname, lua_typename(L, lua_type(L,narg))); - return luaL_argerror(L, narg, msg); -} - - -static void tag_error (lua_State *L, int narg, int tag) { - luaL_typerror(L, narg, lua_typename(L, tag)); -} - - -LUALIB_API void luaL_where (lua_State *L, int level) { - lua_Debug ar; - if (lua_getstack(L, level, &ar)) { /* check function at level */ - lua_getinfo(L, "Snl", &ar); /* get info about it */ - if (ar.currentline > 0) { /* is there info? */ - lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); - return; - } - } - lua_pushliteral(L, ""); /* else, no information available... */ -} - - -LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - va_end(argp); - lua_concat(L, 2); - return lua_error(L); -} - -/* }====================================================== */ - - -LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { - int i; - for (i=0; list[i]; i++) - if (strcmp(list[i], name) == 0) - return i; - return -1; /* name not found */ -} - - -LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { - lua_pushstring(L, tname); - lua_rawget(L, LUA_REGISTRYINDEX); /* get registry.name */ - if (!lua_isnil(L, -1)) /* name already in use? */ - return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_newtable(L); /* create metatable */ - lua_pushstring(L, tname); - lua_pushvalue(L, -2); - lua_rawset(L, LUA_REGISTRYINDEX); /* registry.name = metatable */ - lua_pushvalue(L, -1); - lua_pushstring(L, tname); - lua_rawset(L, LUA_REGISTRYINDEX); /* registry[metatable] = name */ - return 1; -} - - -LUALIB_API void luaL_getmetatable (lua_State *L, const char *tname) { - lua_pushstring(L, tname); - lua_rawget(L, LUA_REGISTRYINDEX); -} - - -LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { - const char *tn; - if (!lua_getmetatable(L, ud)) return NULL; /* no metatable? */ - lua_rawget(L, LUA_REGISTRYINDEX); /* get registry[metatable] */ - tn = lua_tostring(L, -1); - if (tn && (strcmp(tn, tname) == 0)) { - lua_pop(L, 1); - return lua_touserdata(L, ud); - } - else { - lua_pop(L, 1); - return NULL; - } -} - - -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { - if (!lua_checkstack(L, space)) - luaL_error(L, "stack overflow (%s)", mes); -} - - -LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { - if (lua_type(L, narg) != t) - tag_error(L, narg, t); -} - - -LUALIB_API void luaL_checkany (lua_State *L, int narg) { - if (lua_type(L, narg) == LUA_TNONE) - luaL_argerror(L, narg, "value expected"); -} - - -LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { - const char *s = lua_tostring(L, narg); - if (!s) tag_error(L, narg, LUA_TSTRING); - if (len) *len = lua_strlen(L, narg); - return s; -} - - -LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, - const char *def, size_t *len) { - if (lua_isnoneornil(L, narg)) { - if (len) - *len = (def ? strlen(def) : 0); - return def; - } - else return luaL_checklstring(L, narg, len); -} - - -LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { - lua_Number d = lua_tonumber(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ - tag_error(L, narg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { - if (lua_isnoneornil(L, narg)) return def; - else return luaL_checknumber(L, narg); -} - - -LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return 0; - lua_pushstring(L, event); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { - lua_pop(L, 2); /* remove metatable and metafield */ - return 0; - } - else { - lua_remove(L, -2); /* remove only metatable */ - return 1; - } -} - - -LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = abs_index(L, obj); - if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ - return 0; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); - return 1; -} - - -LUALIB_API void luaL_openlib (lua_State *L, const char *libname, - const luaL_reg *l, int nup) { - if (libname) { - lua_pushstring(L, libname); - lua_gettable(L, LUA_GLOBALSINDEX); /* check whether lib already exists */ - if (lua_isnil(L, -1)) { /* no? */ - lua_pop(L, 1); - lua_newtable(L); /* create it */ - lua_pushstring(L, libname); - lua_pushvalue(L, -2); - lua_settable(L, LUA_GLOBALSINDEX); /* register it with given name */ - } - lua_insert(L, -(nup+1)); /* move library table to below upvalues */ - } - for (; l->name; l++) { - int i; - lua_pushstring(L, l->name); - for (i=0; ifunc, nup); - lua_settable(L, -(nup+3)); - } - lua_pop(L, nup); /* remove upvalues */ -} - - - -/* -** {====================================================== -** getn-setn: size for arrays -** ======================================================= -*/ - -static int checkint (lua_State *L, int topop) { - int n = (int)lua_tonumber(L, -1); - if (n == 0 && !lua_isnumber(L, -1)) n = -1; - lua_pop(L, topop); - return n; -} - - -static void getsizes (lua_State *L) { - lua_rawgeti(L, LUA_REGISTRYINDEX, ARRAYSIZE_REF); - if (lua_isnil(L, -1)) { /* no `size' table? */ - lua_pop(L, 1); /* remove nil */ - lua_newtable(L); /* create it */ - lua_pushvalue(L, -1); /* `size' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "__mode"); - lua_pushliteral(L, "k"); - lua_rawset(L, -3); /* metatable(N).__mode = "k" */ - lua_pushvalue(L, -1); - lua_rawseti(L, LUA_REGISTRYINDEX, ARRAYSIZE_REF); /* store in register */ - } -} - - -void luaL_setn (lua_State *L, int t, int n) { - t = abs_index(L, t); - lua_pushliteral(L, "n"); - lua_rawget(L, t); - if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ - lua_pushliteral(L, "n"); /* use it */ - lua_pushnumber(L, (lua_Number)n); - lua_rawset(L, t); - } - else { /* use `sizes' */ - getsizes(L); - lua_pushvalue(L, t); - lua_pushnumber(L, (lua_Number)n); - lua_rawset(L, -3); /* sizes[t] = n */ - lua_pop(L, 1); /* remove `sizes' */ - } -} - - -int luaL_getn (lua_State *L, int t) { - int n; - t = abs_index(L, t); - lua_pushliteral(L, "n"); /* try t.n */ - lua_rawget(L, t); - if ((n = checkint(L, 1)) >= 0) return n; - getsizes(L); /* else try sizes[t] */ - lua_pushvalue(L, t); - lua_rawget(L, -2); - if ((n = checkint(L, 2)) >= 0) return n; - for (n = 1; ; n++) { /* else must count elements */ - lua_rawgeti(L, t, n); - if (lua_isnil(L, -1)) break; - lua_pop(L, 1); - } - lua_pop(L, 1); - return n - 1; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - - -#define bufflen(B) ((B)->p - (B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) - -#define LIMIT (LUA_MINSTACK/2) - - -static int emptybuffer (luaL_Buffer *B) { - size_t l = bufflen(B); - if (l == 0) return 0; /* put nothing on stack */ - else { - lua_pushlstring(B->L, B->buffer, l); - B->p = B->buffer; - B->lvl++; - return 1; - } -} - - -static void adjuststack (luaL_Buffer *B) { - if (B->lvl > 1) { - lua_State *L = B->L; - int toget = 1; /* number of levels to concat */ - size_t toplen = lua_strlen(L, -1); - do { - size_t l = lua_strlen(L, -(toget+1)); - if (B->lvl - toget + 1 >= LIMIT || toplen > l) { - toplen += l; - toget++; - } - else break; - } while (toget < B->lvl); - lua_concat(L, toget); - B->lvl = B->lvl - toget + 1; - } -} - - -LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { - if (emptybuffer(B)) - adjuststack(B); - return B->buffer; -} - - -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - while (l--) - luaL_putchar(B, *s++); -} - - -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { - luaL_addlstring(B, s, strlen(s)); -} - - -LUALIB_API void luaL_pushresult (luaL_Buffer *B) { - emptybuffer(B); - lua_concat(B->L, B->lvl); - B->lvl = 1; -} - - -LUALIB_API void luaL_addvalue (luaL_Buffer *B) { - lua_State *L = B->L; - size_t vl = lua_strlen(L, -1); - if (vl <= bufffree(B)) { /* fit into buffer? */ - memcpy(B->p, lua_tostring(L, -1), vl); /* put it there */ - B->p += vl; - lua_pop(L, 1); /* remove from stack */ - } - else { - if (emptybuffer(B)) - lua_insert(L, -2); /* put buffer before new value */ - B->lvl++; /* add new value into B stack */ - adjuststack(B); - } -} - - -LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { - B->L = L; - B->p = B->buffer; - B->lvl = 0; -} - -/* }====================================================== */ - - -LUALIB_API int luaL_ref (lua_State *L, int t) { - int ref; - t = abs_index(L, t); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* `nil' has a unique fixed reference */ - } - lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ - ref = (int)lua_tonumber(L, -1); /* ref = t[FREELIST_REF] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ - } - else { /* no free elements */ - ref = luaL_getn(L, t); - if (ref < RESERVED_REFS) - ref = RESERVED_REFS; /* skip reserved references */ - ref++; /* create new reference */ - luaL_setn(L, t, ref); - } - lua_rawseti(L, t, ref); - return ref; -} - - -LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { - if (ref >= 0) { - t = abs_index(L, t); - lua_rawgeti(L, t, FREELIST_REF); - lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ - lua_pushnumber(L, (lua_Number)ref); - lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ - } -} - - - -/* -** {====================================================== -** Load functions -** ======================================================= -*/ - -typedef struct LoadF { - FILE *f; - char buff[LUAL_BUFFERSIZE]; -} LoadF; - - -static const char *getF (lua_State *L, void *ud, size_t *size) { - LoadF *lf = (LoadF *)ud; - (void)L; - if (feof(lf->f)) return NULL; - *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); - return (*size > 0) ? lf->buff : NULL; -} - - -static int errfile (lua_State *L, int fnameindex) { - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot read %s: %s", filename, strerror(errno)); - lua_remove(L, fnameindex); - return LUA_ERRFILE; -} - - -LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { - LoadF lf; - int status, readstatus; - int c; - int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ - if (filename == NULL) { - lua_pushliteral(L, "=stdin"); - lf.f = stdin; - } - else { - lua_pushfstring(L, "@%s", filename); - lf.f = fopen(filename, "r"); - } - if (lf.f == NULL) return errfile(L, fnameindex); /* unable to open file */ - c = ungetc(getc(lf.f), lf.f); - if (!(isspace(c) || isprint(c)) && lf.f != stdin) { /* binary file? */ - fclose(lf.f); - lf.f = fopen(filename, "rb"); /* reopen in binary mode */ - if (lf.f == NULL) return errfile(L, fnameindex); /* unable to reopen file */ - } - status = lua_load(L, getF, &lf, lua_tostring(L, -1)); - readstatus = ferror(lf.f); - if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */ - if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from `lua_load' */ - return errfile(L, fnameindex); - } - lua_remove(L, fnameindex); - return status; -} - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - - -static const char *getS (lua_State *L, void *ud, size_t *size) { - LoadS *ls = (LoadS *)ud; - (void)L; - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - - -LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, - const char *name) { - LoadS ls; - ls.s = buff; - ls.size = size; - return lua_load(L, getS, &ls, name); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** compatibility code -** ======================================================= -*/ - - -static void callalert (lua_State *L, int status) { - if (status != 0) { - lua_getglobal(L, "_ALERT"); - if (lua_isfunction(L, -1)) { - lua_insert(L, -2); - lua_call(L, 1, 0); - } - else { /* no _ALERT function; print it on stderr */ - fprintf(stderr, "%s\n", lua_tostring(L, -2)); - lua_pop(L, 2); /* remove error message and _ALERT */ - } - } -} - - -static int aux_do (lua_State *L, int status) { - if (status == 0) { /* parse OK? */ - status = lua_pcall(L, 0, LUA_MULTRET, 0); /* call main */ - } - callalert(L, status); - return status; -} - - -LUALIB_API int lua_dofile (lua_State *L, const char *filename) { - return aux_do(L, luaL_loadfile(L, filename)); -} - - -LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, - const char *name) { - return aux_do(L, luaL_loadbuffer(L, buff, size, name)); -} - - -LUALIB_API int lua_dostring (lua_State *L, const char *str) { - return lua_dobuffer(L, str, strlen(str), str); -} - -/* }====================================================== */ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c + +#include "lua.h" + +#include "lauxlib.h" + + +/* number of prereserved references (for internal use) */ +#define RESERVED_REFS 2 + +/* reserved references */ +#define FREELIST_REF 1 /* free list of references */ +#define ARRAYSIZE_REF 2 /* array sizes */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + lua_getstack(L, 0, &ar); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to `%s' (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, lua_typename(L, lua_type(L,narg))); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Snl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { + int i; + for (i=0; list[i]; i++) + if (strcmp(list[i], name) == 0) + return i; + return -1; /* name not found */ +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_pushstring(L, tname); + lua_rawget(L, LUA_REGISTRYINDEX); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushstring(L, tname); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); /* registry.name = metatable */ + lua_pushvalue(L, -1); + lua_pushstring(L, tname); + lua_rawset(L, LUA_REGISTRYINDEX); /* registry[metatable] = name */ + return 1; +} + + +LUALIB_API void luaL_getmetatable (lua_State *L, const char *tname) { + lua_pushstring(L, tname); + lua_rawget(L, LUA_REGISTRYINDEX); +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + const char *tn; + if (!lua_getmetatable(L, ud)) return NULL; /* no metatable? */ + lua_rawget(L, LUA_REGISTRYINDEX); /* get registry[metatable] */ + tn = lua_tostring(L, -1); + if (tn && (strcmp(tn, tname) == 0)) { + lua_pop(L, 1); + return lua_touserdata(L, ud); + } + else { + lua_pop(L, 1); + return NULL; + } +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tostring(L, narg); + if (!s) tag_error(L, narg, LUA_TSTRING); + if (len) *len = lua_strlen(L, narg); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + if (lua_isnoneornil(L, narg)) return def; + else return luaL_checknumber(L, narg); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void luaL_openlib (lua_State *L, const char *libname, + const luaL_reg *l, int nup) { + if (libname) { + lua_pushstring(L, libname); + lua_gettable(L, LUA_GLOBALSINDEX); /* check whether lib already exists */ + if (lua_isnil(L, -1)) { /* no? */ + lua_pop(L, 1); + lua_newtable(L); /* create it */ + lua_pushstring(L, libname); + lua_pushvalue(L, -2); + lua_settable(L, LUA_GLOBALSINDEX); /* register it with given name */ + } + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + lua_pushstring(L, l->name); + for (i=0; ifunc, nup); + lua_settable(L, -(nup+3)); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +static int checkint (lua_State *L, int topop) { + int n = (int)lua_tonumber(L, -1); + if (n == 0 && !lua_isnumber(L, -1)) n = -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_rawgeti(L, LUA_REGISTRYINDEX, ARRAYSIZE_REF); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "__mode"); + lua_pushliteral(L, "k"); + lua_rawset(L, -3); /* metatable(N).__mode = "k" */ + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_REGISTRYINDEX, ARRAYSIZE_REF); /* store in register */ + } +} + + +void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushnumber(L, (lua_Number)n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushnumber(L, (lua_Number)n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + for (n = 1; ; n++) { /* else must count elements */ + lua_rawgeti(L, t, n); + if (lua_isnil(L, -1)) break; + lua_pop(L, 1); + } + lua_pop(L, 1); + return n - 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_putchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl = lua_strlen(L, -1); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, lua_tostring(L, -1), vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tonumber(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = luaL_getn(L, t); + if (ref < RESERVED_REFS) + ref = RESERVED_REFS; /* skip reserved references */ + ref++; /* create new reference */ + luaL_setn(L, t, ref); + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushnumber(L, (lua_Number)ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, int fnameindex) { + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot read %s: %s", filename, strerror(errno)); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + } + if (lf.f == NULL) return errfile(L, fnameindex); /* unable to open file */ + c = ungetc(getc(lf.f), lf.f); + if (!(isspace(c) || isprint(c)) && lf.f != stdin) { /* binary file? */ + fclose(lf.f); + lf.f = fopen(filename, "rb"); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, fnameindex); /* unable to reopen file */ + } + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** compatibility code +** ======================================================= +*/ + + +static void callalert (lua_State *L, int status) { + if (status != 0) { + lua_getglobal(L, "_ALERT"); + if (lua_isfunction(L, -1)) { + lua_insert(L, -2); + lua_call(L, 1, 0); + } + else { /* no _ALERT function; print it on stderr */ + fprintf(stderr, "%s\n", lua_tostring(L, -2)); + lua_pop(L, 2); /* remove error message and _ALERT */ + } + } +} + + +static int aux_do (lua_State *L, int status) { + if (status == 0) { /* parse OK? */ + status = lua_pcall(L, 0, LUA_MULTRET, 0); /* call main */ + } + callalert(L, status); + return status; +} + + +LUALIB_API int lua_dofile (lua_State *L, const char *filename) { + return aux_do(L, luaL_loadfile(L, filename)); +} + + +LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + return aux_do(L, luaL_loadbuffer(L, buff, size, name)); +} + + +LUALIB_API int lua_dostring (lua_State *L, const char *str) { + return lua_dobuffer(L, str, strlen(str), str); +} + +/* }====================================================== */ diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lbaselib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lbaselib.c index 1b320924d..9f613bcdb 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lbaselib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lbaselib.c @@ -1,684 +1,684 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#include -#include -#include -#include - -#define lbaselib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - - -/* -** If your system does not support `stdout', you can just remove this function. -** If you need, you can define your own `print' function, following this -** model but changing `fputs' to put the strings at a proper place -** (a console window or a log file, for instance). -*/ -static int luaB_print (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tostring(L, -1); /* get result */ - if (s == NULL) - return luaL_error(L, "`tostring' must return a string to `print'"); - if (i>1) fputs("\t", stdout); - fputs(s, stdout); - lua_pop(L, 1); /* pop result */ - } - fputs("\n", stdout); - return 0; -} - - -static int luaB_tonumber (lua_State *L) { - int base = luaL_optint(L, 2, 10); - if (base == 10) { /* standard conversion */ - luaL_checkany(L, 1); - if (lua_isnumber(L, 1)) { - lua_pushnumber(L, lua_tonumber(L, 1)); - return 1; - } - } - else { - const char *s1 = luaL_checkstring(L, 1); - char *s2; - unsigned long n; - luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); - n = strtoul(s1, &s2, base); - if (s1 != s2) { /* at least one valid digit? */ - while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ - if (*s2 == '\0') { /* no invalid trailing characters? */ - lua_pushnumber(L, (lua_Number)n); - return 1; - } - } - } - lua_pushnil(L); /* else not a number */ - return 1; -} - - -static int luaB_error (lua_State *L) { - int level = luaL_optint(L, 2, 1); - luaL_checkany(L, 1); - if (!lua_isstring(L, 1) || level == 0) - lua_pushvalue(L, 1); /* propagate error message without changes */ - else { /* add extra information */ - luaL_where(L, level); - lua_pushvalue(L, 1); - lua_concat(L, 2); - } - return lua_error(L); -} - - -static int luaB_getmetatable (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); - return 1; /* no metatable */ - } - luaL_getmetafield(L, 1, "__metatable"); - return 1; /* returns either __metatable field (if present) or metatable */ -} - - -static int luaB_setmetatable (lua_State *L) { - int t = lua_type(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - if (luaL_getmetafield(L, 1, "__metatable")) - luaL_error(L, "cannot change a protected metatable"); - lua_settop(L, 2); - lua_setmetatable(L, 1); - return 1; -} - - -static void getfunc (lua_State *L) { - if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); - else { - lua_Debug ar; - int level = luaL_optint(L, 1, 1); - luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); - if (lua_getstack(L, level, &ar) == 0) - luaL_argerror(L, 1, "invalid level"); - lua_getinfo(L, "f", &ar); - if (lua_isnil(L, -1)) - luaL_error(L, "no function environment for tail call at level %d", - level); - } -} - - -static int aux_getfenv (lua_State *L) { - lua_getfenv(L, -1); - lua_pushliteral(L, "__fenv"); - lua_rawget(L, -2); - return !lua_isnil(L, -1); -} - - -static int luaB_getfenv (lua_State *L) { - getfunc(L); - if (!aux_getfenv(L)) /* __fenv not defined? */ - lua_pop(L, 1); /* remove it, to return real environment */ - return 1; -} - - -static int luaB_setfenv (lua_State *L) { - luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L); - if (aux_getfenv(L)) /* __fenv defined? */ - luaL_error(L, "`setfenv' cannot change a protected environment"); - else - lua_pop(L, 2); /* remove __fenv and real environment table */ - lua_pushvalue(L, 2); - if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) - lua_replace(L, LUA_GLOBALSINDEX); - else if (lua_setfenv(L, -2) == 0) - luaL_error(L, "`setfenv' cannot change environment of given function"); - return 0; -} - - -static int luaB_rawequal (lua_State *L) { - luaL_checkany(L, 1); - luaL_checkany(L, 2); - lua_pushboolean(L, lua_rawequal(L, 1, 2)); - return 1; -} - - -static int luaB_rawget (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - lua_rawget(L, 1); - return 1; -} - -static int luaB_rawset (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - luaL_checkany(L, 3); - lua_rawset(L, 1); - return 1; -} - - -static int luaB_gcinfo (lua_State *L) { - lua_pushnumber(L, (lua_Number)lua_getgccount(L)); - lua_pushnumber(L, (lua_Number)lua_getgcthreshold(L)); - return 2; -} - - -static int luaB_collectgarbage (lua_State *L) { - lua_setgcthreshold(L, luaL_optint(L, 1, 0)); - return 0; -} - - -static int luaB_type (lua_State *L) { - luaL_checkany(L, 1); - lua_pushstring(L, lua_typename(L, lua_type(L, 1))); - return 1; -} - - -static int luaB_next (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 2); /* create a 2nd argument if there isn't one */ - if (lua_next(L, 1)) - return 2; - else { - lua_pushnil(L); - return 1; - } -} - - -static int luaB_pairs (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushliteral(L, "next"); - lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushnil(L); /* and initial value */ - return 3; -} - - -static int luaB_ipairs (lua_State *L) { - lua_Number i = lua_tonumber(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */ - lua_pushliteral(L, "ipairs"); - lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */ - lua_pushvalue(L, 1); /* state, */ - lua_pushnumber(L, 0); /* and initial value */ - return 3; - } - else { /* `for' step */ - i++; /* next value */ - lua_pushnumber(L, i); - lua_rawgeti(L, 1, (int)i); - return (lua_isnil(L, -1)) ? 0 : 2; - } -} - - -static int load_aux (lua_State *L, int status) { - if (status == 0) /* OK? */ - return 1; - else { - lua_pushnil(L); - lua_insert(L, -2); /* put before error message */ - return 2; /* return nil plus error message */ - } -} - - -static int luaB_loadstring (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - const char *chunkname = luaL_optstring(L, 2, s); - return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); -} - - -static int luaB_loadfile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - return load_aux(L, luaL_loadfile(L, fname)); -} - - -static int luaB_dofile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - int status = luaL_loadfile(L, fname); - if (status != 0) lua_error(L); - lua_call(L, 0, LUA_MULTRET); - return lua_gettop(L) - 1; -} - - -static int luaB_assert (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_toboolean(L, 1)) - return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); - lua_settop(L, 1); - return 1; -} - - -static int luaB_unpack (lua_State *L) { - int n, i; - luaL_checktype(L, 1, LUA_TTABLE); - n = luaL_getn(L, 1); - luaL_checkstack(L, n, "table too big to unpack"); - for (i=1; i<=n; i++) /* push arg[1...n] */ - lua_rawgeti(L, 1, i); - return n; -} - - -static int luaB_pcall (lua_State *L) { - int status; - luaL_checkany(L, 1); - status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); - lua_pushboolean(L, (status == 0)); - lua_insert(L, 1); - return lua_gettop(L); /* return status + all results */ -} - - -static int luaB_xpcall (lua_State *L) { - int status; - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_insert(L, 1); /* put error function under function to be called */ - status = lua_pcall(L, 0, LUA_MULTRET, 1); - lua_pushboolean(L, (status == 0)); - lua_replace(L, 1); - return lua_gettop(L); /* return status + all results */ -} - - -static int luaB_tostring (lua_State *L) { - char buff[64]; - luaL_checkany(L, 1); - if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ - return 1; /* use its value */ - switch (lua_type(L, 1)) { - case LUA_TNUMBER: - lua_pushstring(L, lua_tostring(L, 1)); - return 1; - case LUA_TSTRING: - lua_pushvalue(L, 1); - return 1; - case LUA_TBOOLEAN: - lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); - return 1; - case LUA_TTABLE: - sprintf(buff, "table: %p", lua_topointer(L, 1)); - break; - case LUA_TFUNCTION: - sprintf(buff, "function: %p", lua_topointer(L, 1)); - break; - case LUA_TUSERDATA: - case LUA_TLIGHTUSERDATA: - sprintf(buff, "userdata: %p", lua_touserdata(L, 1)); - break; - case LUA_TTHREAD: - sprintf(buff, "thread: %p", (void *)lua_tothread(L, 1)); - break; - case LUA_TNIL: - lua_pushliteral(L, "nil"); - return 1; - } - lua_pushstring(L, buff); - return 1; -} - - -static int luaB_newproxy (lua_State *L) { - lua_settop(L, 1); - lua_newuserdata(L, 0); /* create proxy */ - if (lua_toboolean(L, 1) == 0) - return 1; /* no metatable */ - else if (lua_isboolean(L, 1)) { - lua_newtable(L); /* create a new metatable `m' ... */ - lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ - lua_pushboolean(L, 1); - lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ - } - else { - int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ - if (lua_getmetatable(L, 1)) { - lua_rawget(L, lua_upvalueindex(1)); - validproxy = lua_toboolean(L, -1); - lua_pop(L, 1); /* remove value */ - } - luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); - lua_getmetatable(L, 1); /* metatable is valid; get it */ - } - lua_setmetatable(L, 2); - return 1; -} - - -/* -** {====================================================== -** `require' function -** ======================================================= -*/ - - -/* name of global that holds table with loaded packages */ -#define REQTAB "_LOADED" - -/* name of global that holds the search path for packages */ -#define LUA_PATH "LUA_PATH" - -#ifndef LUA_PATH_SEP -#define LUA_PATH_SEP ';' -#endif - -#ifndef LUA_PATH_MARK -#define LUA_PATH_MARK '?' -#endif - -#ifndef LUA_PATH_DEFAULT -#define LUA_PATH_DEFAULT "?;?.lua" -#endif - - -static const char *getpath (lua_State *L) { - const char *path; - lua_getglobal(L, LUA_PATH); /* try global variable */ - path = lua_tostring(L, -1); - lua_pop(L, 1); - if (path) return path; - path = getenv(LUA_PATH); /* else try environment variable */ - if (path) return path; - return LUA_PATH_DEFAULT; /* else use default */ -} - - -static const char *pushnextpath (lua_State *L, const char *path) { - const char *l; - if (*path == '\0') return NULL; /* no more paths */ - if (*path == LUA_PATH_SEP) path++; /* skip separator */ - l = strchr(path, LUA_PATH_SEP); /* find next separator */ - if (l == NULL) l = path+strlen(path); - lua_pushlstring(L, path, l - path); /* directory name */ - return l; -} - - -static void pushcomposename (lua_State *L) { - const char *path = lua_tostring(L, -1); - const char *wild; - int n = 1; - while ((wild = strchr(path, LUA_PATH_MARK)) != NULL) { - /* is there stack space for prefix, name, and eventual last sufix? */ - luaL_checkstack(L, 3, "too many marks in a path component"); - lua_pushlstring(L, path, wild - path); /* push prefix */ - lua_pushvalue(L, 1); /* push package name (in place of MARK) */ - path = wild + 1; /* continue after MARK */ - n += 2; - } - lua_pushstring(L, path); /* push last sufix (`n' already includes this) */ - lua_concat(L, n); -} - - -static int luaB_require (lua_State *L) { - const char *path; - int status = LUA_ERRFILE; /* not found (yet) */ - luaL_checkstring(L, 1); - lua_settop(L, 1); - lua_getglobal(L, REQTAB); - if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table"); - path = getpath(L); - lua_pushvalue(L, 1); /* check package's name in book-keeping table */ - lua_rawget(L, 2); - if (lua_toboolean(L, -1)) /* is it there? */ - return 1; /* package is already loaded; return its result */ - else { /* must load it */ - while (status == LUA_ERRFILE) { - lua_settop(L, 3); /* reset stack position */ - if ((path = pushnextpath(L, path)) == NULL) break; - pushcomposename(L); - status = luaL_loadfile(L, lua_tostring(L, -1)); /* try to load it */ - } - } - switch (status) { - case 0: { - lua_getglobal(L, "_REQUIREDNAME"); /* save previous name */ - lua_insert(L, -2); /* put it below function */ - lua_pushvalue(L, 1); - lua_setglobal(L, "_REQUIREDNAME"); /* set new name */ - lua_call(L, 0, 1); /* run loaded module */ - lua_insert(L, -2); /* put result below previous name */ - lua_setglobal(L, "_REQUIREDNAME"); /* reset to previous name */ - if (lua_isnil(L, -1)) { /* no/nil return? */ - lua_pushboolean(L, 1); - lua_replace(L, -2); /* replace to true */ - } - lua_pushvalue(L, 1); - lua_pushvalue(L, -2); - lua_rawset(L, 2); /* mark it as loaded */ - return 1; /* return value */ - } - case LUA_ERRFILE: { /* file not found */ - return luaL_error(L, "could not load package `%s' from path `%s'", - lua_tostring(L, 1), getpath(L)); - } - default: { - return luaL_error(L, "error loading package `%s' (%s)", - lua_tostring(L, 1), lua_tostring(L, -1)); - } - } -} - -/* }====================================================== */ - - -static const luaL_reg base_funcs[] = { - {"error", luaB_error}, - {"getmetatable", luaB_getmetatable}, - {"setmetatable", luaB_setmetatable}, - {"getfenv", luaB_getfenv}, - {"setfenv", luaB_setfenv}, - {"next", luaB_next}, - {"ipairs", luaB_ipairs}, - {"pairs", luaB_pairs}, - {"print", luaB_print}, - {"tonumber", luaB_tonumber}, - {"tostring", luaB_tostring}, - {"type", luaB_type}, - {"assert", luaB_assert}, - {"unpack", luaB_unpack}, - {"rawequal", luaB_rawequal}, - {"rawget", luaB_rawget}, - {"rawset", luaB_rawset}, - {"pcall", luaB_pcall}, - {"xpcall", luaB_xpcall}, - {"collectgarbage", luaB_collectgarbage}, - {"gcinfo", luaB_gcinfo}, - {"loadfile", luaB_loadfile}, - {"dofile", luaB_dofile}, - {"loadstring", luaB_loadstring}, - {"require", luaB_require}, - {NULL, NULL} -}; - - -/* -** {====================================================== -** Coroutine library -** ======================================================= -*/ - -static int auxresume (lua_State *L, lua_State *co, int narg) { - int status; - if (!lua_checkstack(co, narg)) - luaL_error(L, "too many arguments to resume"); - lua_xmove(L, co, narg); - status = lua_resume(co, narg); - if (status == 0) { - int nres = lua_gettop(co); - if (!lua_checkstack(L, nres)) - luaL_error(L, "too many results to resume"); - lua_xmove(co, L, nres); /* move yielded values */ - return nres; - } - else { - lua_xmove(co, L, 1); /* move error message */ - return -1; /* error flag */ - } -} - - -static int luaB_coresume (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - int r; - luaL_argcheck(L, co, 1, "coroutine expected"); - r = auxresume(L, co, lua_gettop(L) - 1); - if (r < 0) { - lua_pushboolean(L, 0); - lua_insert(L, -2); - return 2; /* return false + error message */ - } - else { - lua_pushboolean(L, 1); - lua_insert(L, -(r + 1)); - return r + 1; /* return true + `resume' returns */ - } -} - - -static int luaB_auxwrap (lua_State *L) { - lua_State *co = lua_tothread(L, lua_upvalueindex(1)); - int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { - if (lua_isstring(L, -1)) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ - lua_insert(L, -2); - lua_concat(L, 2); - } - lua_error(L); /* propagate error */ - } - return r; -} - - -static int luaB_cocreate (lua_State *L) { - lua_State *NL = lua_newthread(L); - luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, - "Lua function expected"); - lua_pushvalue(L, 1); /* move function to top */ - lua_xmove(L, NL, 1); /* move function from L to NL */ - return 1; -} - - -static int luaB_cowrap (lua_State *L) { - luaB_cocreate(L); - lua_pushcclosure(L, luaB_auxwrap, 1); - return 1; -} - - -static int luaB_yield (lua_State *L) { - return lua_yield(L, lua_gettop(L)); -} - - -static int luaB_costatus (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "coroutine expected"); - if (L == co) lua_pushliteral(L, "running"); - else { - lua_Debug ar; - if (lua_getstack(co, 0, &ar) == 0 && lua_gettop(co) == 0) - lua_pushliteral(L, "dead"); - else - lua_pushliteral(L, "suspended"); - } - return 1; -} - - -static const luaL_reg co_funcs[] = { - {"create", luaB_cocreate}, - {"wrap", luaB_cowrap}, - {"resume", luaB_coresume}, - {"yield", luaB_yield}, - {"status", luaB_costatus}, - {NULL, NULL} -}; - -/* }====================================================== */ - - - -static void base_open (lua_State *L) { - lua_pushliteral(L, "_G"); - lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */ - lua_pushliteral(L, "_VERSION"); - lua_pushliteral(L, LUA_VERSION); - lua_rawset(L, -3); /* set global _VERSION */ - /* `newproxy' needs a weaktable as upvalue */ - lua_pushliteral(L, "newproxy"); - lua_newtable(L); /* new table `w' */ - lua_pushvalue(L, -1); /* `w' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "__mode"); - lua_pushliteral(L, "k"); - lua_rawset(L, -3); /* metatable(w).__mode = "k" */ - lua_pushcclosure(L, luaB_newproxy, 1); - lua_rawset(L, -3); /* set global `newproxy' */ - lua_rawset(L, -1); /* set global _G */ -} - - -LUALIB_API int luaopen_base (lua_State *L) { - base_open(L); - luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0); - lua_newtable(L); - lua_setglobal(L, REQTAB); - return 0; -} - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#include +#include +#include +#include + +#define lbaselib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, "`tostring' must return a string to `print'"); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + luaL_checkany(L, 1); + if (!lua_isstring(L, 1) || level == 0) + lua_pushvalue(L, 1); /* propagate error message without changes */ + else { /* add extra information */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = luaL_optint(L, 1, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int aux_getfenv (lua_State *L) { + lua_getfenv(L, -1); + lua_pushliteral(L, "__fenv"); + lua_rawget(L, -2); + return !lua_isnil(L, -1); +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L); + if (!aux_getfenv(L)) /* __fenv not defined? */ + lua_pop(L, 1); /* remove it, to return real environment */ + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L); + if (aux_getfenv(L)) /* __fenv defined? */ + luaL_error(L, "`setfenv' cannot change a protected environment"); + else + lua_pop(L, 2); /* remove __fenv and real environment table */ + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) + lua_replace(L, LUA_GLOBALSINDEX); + else if (lua_setfenv(L, -2) == 0) + luaL_error(L, "`setfenv' cannot change environment of given function"); + return 0; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushnumber(L, (lua_Number)lua_getgccount(L)); + lua_pushnumber(L, (lua_Number)lua_getgcthreshold(L)); + return 2; +} + + +static int luaB_collectgarbage (lua_State *L) { + lua_setgcthreshold(L, luaL_optint(L, 1, 0)); + return 0; +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, lua_typename(L, lua_type(L, 1))); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushliteral(L, "next"); + lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int luaB_ipairs (lua_State *L) { + lua_Number i = lua_tonumber(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */ + lua_pushliteral(L, "ipairs"); + lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnumber(L, 0); /* and initial value */ + return 3; + } + else { /* `for' step */ + i++; /* next value */ + lua_pushnumber(L, i); + lua_rawgeti(L, 1, (int)i); + return (lua_isnil(L, -1)) ? 0 : 2; + } +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int status = luaL_loadfile(L, fname); + if (status != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - 1; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + lua_settop(L, 1); + return 1; +} + + +static int luaB_unpack (lua_State *L) { + int n, i; + luaL_checktype(L, 1, LUA_TTABLE); + n = luaL_getn(L, 1); + luaL_checkstack(L, n, "table too big to unpack"); + for (i=1; i<=n; i++) /* push arg[1...n] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + char buff[64]; + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + return 1; + case LUA_TSTRING: + lua_pushvalue(L, 1); + return 1; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + return 1; + case LUA_TTABLE: + sprintf(buff, "table: %p", lua_topointer(L, 1)); + break; + case LUA_TFUNCTION: + sprintf(buff, "function: %p", lua_topointer(L, 1)); + break; + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + sprintf(buff, "userdata: %p", lua_touserdata(L, 1)); + break; + case LUA_TTHREAD: + sprintf(buff, "thread: %p", (void *)lua_tothread(L, 1)); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + return 1; + } + lua_pushstring(L, buff); + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +/* +** {====================================================== +** `require' function +** ======================================================= +*/ + + +/* name of global that holds table with loaded packages */ +#define REQTAB "_LOADED" + +/* name of global that holds the search path for packages */ +#define LUA_PATH "LUA_PATH" + +#ifndef LUA_PATH_SEP +#define LUA_PATH_SEP ';' +#endif + +#ifndef LUA_PATH_MARK +#define LUA_PATH_MARK '?' +#endif + +#ifndef LUA_PATH_DEFAULT +#define LUA_PATH_DEFAULT "?;?.lua" +#endif + + +static const char *getpath (lua_State *L) { + const char *path; + lua_getglobal(L, LUA_PATH); /* try global variable */ + path = lua_tostring(L, -1); + lua_pop(L, 1); + if (path) return path; + path = getenv(LUA_PATH); /* else try environment variable */ + if (path) return path; + return LUA_PATH_DEFAULT; /* else use default */ +} + + +static const char *pushnextpath (lua_State *L, const char *path) { + const char *l; + if (*path == '\0') return NULL; /* no more paths */ + if (*path == LUA_PATH_SEP) path++; /* skip separator */ + l = strchr(path, LUA_PATH_SEP); /* find next separator */ + if (l == NULL) l = path+strlen(path); + lua_pushlstring(L, path, l - path); /* directory name */ + return l; +} + + +static void pushcomposename (lua_State *L) { + const char *path = lua_tostring(L, -1); + const char *wild; + int n = 1; + while ((wild = strchr(path, LUA_PATH_MARK)) != NULL) { + /* is there stack space for prefix, name, and eventual last sufix? */ + luaL_checkstack(L, 3, "too many marks in a path component"); + lua_pushlstring(L, path, wild - path); /* push prefix */ + lua_pushvalue(L, 1); /* push package name (in place of MARK) */ + path = wild + 1; /* continue after MARK */ + n += 2; + } + lua_pushstring(L, path); /* push last sufix (`n' already includes this) */ + lua_concat(L, n); +} + + +static int luaB_require (lua_State *L) { + const char *path; + int status = LUA_ERRFILE; /* not found (yet) */ + luaL_checkstring(L, 1); + lua_settop(L, 1); + lua_getglobal(L, REQTAB); + if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table"); + path = getpath(L); + lua_pushvalue(L, 1); /* check package's name in book-keeping table */ + lua_rawget(L, 2); + if (lua_toboolean(L, -1)) /* is it there? */ + return 1; /* package is already loaded; return its result */ + else { /* must load it */ + while (status == LUA_ERRFILE) { + lua_settop(L, 3); /* reset stack position */ + if ((path = pushnextpath(L, path)) == NULL) break; + pushcomposename(L); + status = luaL_loadfile(L, lua_tostring(L, -1)); /* try to load it */ + } + } + switch (status) { + case 0: { + lua_getglobal(L, "_REQUIREDNAME"); /* save previous name */ + lua_insert(L, -2); /* put it below function */ + lua_pushvalue(L, 1); + lua_setglobal(L, "_REQUIREDNAME"); /* set new name */ + lua_call(L, 0, 1); /* run loaded module */ + lua_insert(L, -2); /* put result below previous name */ + lua_setglobal(L, "_REQUIREDNAME"); /* reset to previous name */ + if (lua_isnil(L, -1)) { /* no/nil return? */ + lua_pushboolean(L, 1); + lua_replace(L, -2); /* replace to true */ + } + lua_pushvalue(L, 1); + lua_pushvalue(L, -2); + lua_rawset(L, 2); /* mark it as loaded */ + return 1; /* return value */ + } + case LUA_ERRFILE: { /* file not found */ + return luaL_error(L, "could not load package `%s' from path `%s'", + lua_tostring(L, 1), getpath(L)); + } + default: { + return luaL_error(L, "error loading package `%s' (%s)", + lua_tostring(L, 1), lua_tostring(L, -1)); + } + } +} + +/* }====================================================== */ + + +static const luaL_reg base_funcs[] = { + {"error", luaB_error}, + {"getmetatable", luaB_getmetatable}, + {"setmetatable", luaB_setmetatable}, + {"getfenv", luaB_getfenv}, + {"setfenv", luaB_setfenv}, + {"next", luaB_next}, + {"ipairs", luaB_ipairs}, + {"pairs", luaB_pairs}, + {"print", luaB_print}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"assert", luaB_assert}, + {"unpack", luaB_unpack}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"pcall", luaB_pcall}, + {"xpcall", luaB_xpcall}, + {"collectgarbage", luaB_collectgarbage}, + {"gcinfo", luaB_gcinfo}, + {"loadfile", luaB_loadfile}, + {"dofile", luaB_dofile}, + {"loadstring", luaB_loadstring}, + {"require", luaB_require}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status; + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + lua_xmove(L, co, narg); + status = lua_resume(co, narg); + if (status == 0) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + if (L == co) lua_pushliteral(L, "running"); + else { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) == 0 && lua_gettop(co) == 0) + lua_pushliteral(L, "dead"); + else + lua_pushliteral(L, "suspended"); + } + return 1; +} + + +static const luaL_reg co_funcs[] = { + {"create", luaB_cocreate}, + {"wrap", luaB_cowrap}, + {"resume", luaB_coresume}, + {"yield", luaB_yield}, + {"status", luaB_costatus}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +static void base_open (lua_State *L) { + lua_pushliteral(L, "_G"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */ + lua_pushliteral(L, "_VERSION"); + lua_pushliteral(L, LUA_VERSION); + lua_rawset(L, -3); /* set global _VERSION */ + /* `newproxy' needs a weaktable as upvalue */ + lua_pushliteral(L, "newproxy"); + lua_newtable(L); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "__mode"); + lua_pushliteral(L, "k"); + lua_rawset(L, -3); /* metatable(w).__mode = "k" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_rawset(L, -3); /* set global `newproxy' */ + lua_rawset(L, -1); /* set global _G */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0); + lua_newtable(L); + lua_setglobal(L, REQTAB); + return 0; +} + diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ldblib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ldblib.c index 55d4d042c..8424a3784 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ldblib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ldblib.c @@ -1,309 +1,309 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include - -#define ldblib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - -static void settabss (lua_State *L, const char *i, const char *v) { - lua_pushstring(L, i); - lua_pushstring(L, v); - lua_rawset(L, -3); -} - - -static void settabsi (lua_State *L, const char *i, int v) { - lua_pushstring(L, i); - lua_pushnumber(L, (lua_Number)v); - lua_rawset(L, -3); -} - - -static int getinfo (lua_State *L) { - lua_Debug ar; - const char *options = luaL_optstring(L, 2, "flnSu"); - if (lua_isnumber(L, 1)) { - if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { - lua_pushnil(L); /* level out of range */ - return 1; - } - } - else if (lua_isfunction(L, 1)) { - lua_pushfstring(L, ">%s", options); - options = lua_tostring(L, -1); - lua_pushvalue(L, 1); - } - else - return luaL_argerror(L, 1, "function or level expected"); - if (!lua_getinfo(L, options, &ar)) - return luaL_argerror(L, 2, "invalid option"); - lua_newtable(L); - for (; *options; options++) { - switch (*options) { - case 'S': - settabss(L, "source", ar.source); - settabss(L, "short_src", ar.short_src); - settabsi(L, "linedefined", ar.linedefined); - settabss(L, "what", ar.what); - break; - case 'l': - settabsi(L, "currentline", ar.currentline); - break; - case 'u': - settabsi(L, "nups", ar.nups); - break; - case 'n': - settabss(L, "name", ar.name); - settabss(L, "namewhat", ar.namewhat); - break; - case 'f': - lua_pushliteral(L, "func"); - lua_pushvalue(L, -3); - lua_rawset(L, -3); - break; - } - } - return 1; /* return table */ -} - - -static int getlocal (lua_State *L) { - lua_Debug ar; - const char *name; - if (!lua_getstack(L, luaL_checkint(L, 1), &ar)) /* level out of range? */ - return luaL_argerror(L, 1, "level out of range"); - name = lua_getlocal(L, &ar, luaL_checkint(L, 2)); - if (name) { - lua_pushstring(L, name); - lua_pushvalue(L, -2); - return 2; - } - else { - lua_pushnil(L); - return 1; - } -} - - -static int setlocal (lua_State *L) { - lua_Debug ar; - if (!lua_getstack(L, luaL_checkint(L, 1), &ar)) /* level out of range? */ - return luaL_argerror(L, 1, "level out of range"); - luaL_checkany(L, 3); - lua_pushstring(L, lua_setlocal(L, &ar, luaL_checkint(L, 2))); - return 1; -} - - -static int auxupvalue (lua_State *L, int get) { - const char *name; - int n = luaL_checkint(L, 2); - luaL_checktype(L, 1, LUA_TFUNCTION); - if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ - name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); - if (name == NULL) return 0; - lua_pushstring(L, name); - lua_insert(L, -(get+1)); - return get + 1; -} - - -static int getupvalue (lua_State *L) { - return auxupvalue(L, 1); -} - - -static int setupvalue (lua_State *L) { - luaL_checkany(L, 3); - return auxupvalue(L, 0); -} - - - -static const char KEY_HOOK = 'h'; - - -static void hookf (lua_State *L, lua_Debug *ar) { - static const char *const hooknames[] = - {"call", "return", "line", "count", "tail return"}; - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_isfunction(L, -1)) { - lua_pushstring(L, hooknames[(int)ar->event]); - if (ar->currentline >= 0) - lua_pushnumber(L, (lua_Number)ar->currentline); - else lua_pushnil(L); - lua_assert(lua_getinfo(L, "lS", ar)); - lua_call(L, 2, 0); - } - else - lua_pop(L, 1); /* pop result from gettable */ -} - - -static int makemask (const char *smask, int count) { - int mask = 0; - if (strchr(smask, 'c')) mask |= LUA_MASKCALL; - if (strchr(smask, 'r')) mask |= LUA_MASKRET; - if (strchr(smask, 'l')) mask |= LUA_MASKLINE; - if (count > 0) mask |= LUA_MASKCOUNT; - return mask; -} - - -static char *unmakemask (int mask, char *smask) { - int i = 0; - if (mask & LUA_MASKCALL) smask[i++] = 'c'; - if (mask & LUA_MASKRET) smask[i++] = 'r'; - if (mask & LUA_MASKLINE) smask[i++] = 'l'; - smask[i] = '\0'; - return smask; -} - - -static int sethook (lua_State *L) { - if (lua_isnoneornil(L, 1)) { - lua_settop(L, 1); - lua_sethook(L, NULL, 0, 0); /* turn off hooks */ - } - else { - const char *smask = luaL_checkstring(L, 2); - int count = luaL_optint(L, 3, 0); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_sethook(L, hookf, makemask(smask, count), count); - } - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_pushvalue(L, 1); - lua_rawset(L, LUA_REGISTRYINDEX); /* set new hook */ - return 0; -} - - -static int gethook (lua_State *L) { - char buff[5]; - int mask = lua_gethookmask(L); - lua_Hook hook = lua_gethook(L); - if (hook != NULL && hook != hookf) /* external hook? */ - lua_pushliteral(L, "external hook"); - else { - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ - } - lua_pushstring(L, unmakemask(mask, buff)); - lua_pushnumber(L, (lua_Number)lua_gethookcount(L)); - return 3; -} - - -static int debug (lua_State *L) { - for (;;) { - char buffer[250]; - fputs("lua_debug> ", stderr); - if (fgets(buffer, sizeof(buffer), stdin) == 0 || - strcmp(buffer, "cont\n") == 0) - return 0; - lua_dostring(L, buffer); - lua_settop(L, 0); /* remove eventual returns */ - } -} - - -#define LEVELS1 12 /* size of the first part of the stack */ -#define LEVELS2 10 /* size of the second part of the stack */ - -static int errorfb (lua_State *L) { - int level = 1; /* skip level 0 (it's this function) */ - int firstpart = 1; /* still before eventual `...' */ - lua_Debug ar; - if (lua_gettop(L) == 0) - lua_pushliteral(L, ""); - else if (!lua_isstring(L, 1)) return 1; /* no string message */ - else lua_pushliteral(L, "\n"); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L, level++, &ar)) { - if (level > LEVELS1 && firstpart) { - /* no more than `LEVELS2' more levels? */ - if (!lua_getstack(L, level+LEVELS2, &ar)) - level--; /* keep going */ - else { - lua_pushliteral(L, "\n\t..."); /* too many levels */ - while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */ - level++; - } - firstpart = 0; - continue; - } - lua_pushliteral(L, "\n\t"); - lua_getinfo(L, "Snl", &ar); - lua_pushfstring(L, "%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - switch (*ar.namewhat) { - case 'g': /* global */ - case 'l': /* local */ - case 'f': /* field */ - case 'm': /* method */ - lua_pushfstring(L, " in function `%s'", ar.name); - break; - default: { - if (*ar.what == 'm') /* main? */ - lua_pushfstring(L, " in main chunk"); - else if (*ar.what == 'C' || *ar.what == 't') - lua_pushliteral(L, " ?"); /* C function or tail call */ - else - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); - } - } - lua_concat(L, lua_gettop(L)); - } - lua_concat(L, lua_gettop(L)); - return 1; -} - - -static const luaL_reg dblib[] = { - {"getlocal", getlocal}, - {"getinfo", getinfo}, - {"gethook", gethook}, - {"getupvalue", getupvalue}, - {"sethook", sethook}, - {"setlocal", setlocal}, - {"setupvalue", setupvalue}, - {"debug", debug}, - {"traceback", errorfb}, - {NULL, NULL} -}; - - -LUALIB_API int luaopen_debug (lua_State *L) { - luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); - lua_pushliteral(L, "_TRACEBACK"); - lua_pushcfunction(L, errorfb); - lua_settable(L, LUA_GLOBALSINDEX); - return 1; -} - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include +#include +#include + +#define ldblib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, i); + lua_pushstring(L, v); + lua_rawset(L, -3); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushstring(L, i); + lua_pushnumber(L, (lua_Number)v); + lua_rawset(L, -3); +} + + +static int getinfo (lua_State *L) { + lua_Debug ar; + const char *options = luaL_optstring(L, 2, "flnSu"); + if (lua_isnumber(L, 1)) { + if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, 1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, 1); + } + else + return luaL_argerror(L, 1, "function or level expected"); + if (!lua_getinfo(L, options, &ar)) + return luaL_argerror(L, 2, "invalid option"); + lua_newtable(L); + for (; *options; options++) { + switch (*options) { + case 'S': + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabss(L, "what", ar.what); + break; + case 'l': + settabsi(L, "currentline", ar.currentline); + break; + case 'u': + settabsi(L, "nups", ar.nups); + break; + case 'n': + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + break; + case 'f': + lua_pushliteral(L, "func"); + lua_pushvalue(L, -3); + lua_rawset(L, -3); + break; + } + } + return 1; /* return table */ +} + + +static int getlocal (lua_State *L) { + lua_Debug ar; + const char *name; + if (!lua_getstack(L, luaL_checkint(L, 1), &ar)) /* level out of range? */ + return luaL_argerror(L, 1, "level out of range"); + name = lua_getlocal(L, &ar, luaL_checkint(L, 2)); + if (name) { + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int setlocal (lua_State *L) { + lua_Debug ar; + if (!lua_getstack(L, luaL_checkint(L, 1), &ar)) /* level out of range? */ + return luaL_argerror(L, 1, "level out of range"); + luaL_checkany(L, 3); + lua_pushstring(L, lua_setlocal(L, &ar, luaL_checkint(L, 2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushnumber(L, (lua_Number)ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } + else + lua_pop(L, 1); /* pop result from gettable */ +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static int sethook (lua_State *L) { + if (lua_isnoneornil(L, 1)) { + lua_settop(L, 1); + lua_sethook(L, NULL, 0, 0); /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, 2); + int count = luaL_optint(L, 3, 0); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_sethook(L, hookf, makemask(smask, count), count); + } + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, 1); + lua_rawset(L, LUA_REGISTRYINDEX); /* set new hook */ + return 0; +} + + +static int gethook (lua_State *L) { + char buff[5]; + int mask = lua_gethookmask(L); + lua_Hook hook = lua_gethook(L); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushnumber(L, (lua_Number)lua_gethookcount(L)); + return 3; +} + + +static int debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + lua_dostring(L, buffer); + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int errorfb (lua_State *L) { + int level = 1; /* skip level 0 (it's this function) */ + int firstpart = 1; /* still before eventual `...' */ + lua_Debug ar; + if (lua_gettop(L) == 0) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, 1)) return 1; /* no string message */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + switch (*ar.namewhat) { + case 'g': /* global */ + case 'l': /* local */ + case 'f': /* field */ + case 'm': /* method */ + lua_pushfstring(L, " in function `%s'", ar.name); + break; + default: { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + } + lua_concat(L, lua_gettop(L)); + } + lua_concat(L, lua_gettop(L)); + return 1; +} + + +static const luaL_reg dblib[] = { + {"getlocal", getlocal}, + {"getinfo", getinfo}, + {"gethook", gethook}, + {"getupvalue", getupvalue}, + {"sethook", sethook}, + {"setlocal", setlocal}, + {"setupvalue", setupvalue}, + {"debug", debug}, + {"traceback", errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); + lua_pushliteral(L, "_TRACEBACK"); + lua_pushcfunction(L, errorfb); + lua_settable(L, LUA_GLOBALSINDEX); + return 1; +} + diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/liolib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/liolib.c index 01281e273..1aa0cc5bc 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/liolib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/liolib.c @@ -1,760 +1,760 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include -#include - -#define liolib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - - -/* -** by default, gcc does not get `tmpname' -*/ -#ifndef USE_TMPNAME -#ifdef __GNUC__ -#define USE_TMPNAME 0 -#else -#define USE_TMPNAME 1 -#endif -#endif - - -/* -** by default, posix systems get `popen' -*/ -#ifndef USE_POPEN -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 2 -#define USE_POPEN 1 -#endif -#endif -#endif - -#ifndef USE_POPEN -#define USE_POPEN 0 -#endif - - - - -/* -** {====================================================== -** FILE Operations -** ======================================================= -*/ - - -#if !USE_POPEN -#define pclose(f) (-1) -#endif - - -#define FILEHANDLE "FILE*" - -#define IO_INPUT "_input" -#define IO_OUTPUT "_output" - - -static int pushresult (lua_State *L, int i, const char *filename) { - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - if (filename) - lua_pushfstring(L, "%s: %s", filename, strerror(errno)); - else - lua_pushfstring(L, "%s", strerror(errno)); - lua_pushnumber(L, errno); - return 3; - } -} - - -static FILE **topfile (lua_State *L, int findex) { - FILE **f = (FILE **)luaL_checkudata(L, findex, FILEHANDLE); - if (f == NULL) luaL_argerror(L, findex, "bad file"); - return f; -} - - -static int io_type (lua_State *L) { - FILE **f = (FILE **)luaL_checkudata(L, 1, FILEHANDLE); - if (f == NULL) lua_pushnil(L); - else if (*f == NULL) - lua_pushliteral(L, "closed file"); - else - lua_pushliteral(L, "file"); - return 1; -} - - -static FILE *tofile (lua_State *L, int findex) { - FILE **f = topfile(L, findex); - if (*f == NULL) - luaL_error(L, "attempt to use a closed file"); - return *f; -} - - - -/* -** When creating file handles, always creates a `closed' file handle -** before opening the actual file; so, if there is a memory error, the -** file is not left opened. -*/ -static FILE **newfile (lua_State *L) { - FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); - *pf = NULL; /* file handle is currently `closed' */ - luaL_getmetatable(L, FILEHANDLE); - lua_setmetatable(L, -2); - return pf; -} - - -/* -** assumes that top of the stack is the `io' library, and next is -** the `io' metatable -*/ -static void registerfile (lua_State *L, FILE *f, const char *name, - const char *impname) { - lua_pushstring(L, name); - *newfile(L) = f; - if (impname) { - lua_pushstring(L, impname); - lua_pushvalue(L, -2); - lua_settable(L, -6); /* metatable[impname] = file */ - } - lua_settable(L, -3); /* io[name] = file */ -} - - -static int aux_close (lua_State *L) { - FILE *f = tofile(L, 1); - if (f == stdin || f == stdout || f == stderr) - return 0; /* file cannot be closed */ - else { - int ok = (pclose(f) != -1) || (fclose(f) == 0); - if (ok) - *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ - return ok; - } -} - - -static int io_close (lua_State *L) { - if (lua_isnone(L, 1)) { - lua_pushstring(L, IO_OUTPUT); - lua_rawget(L, lua_upvalueindex(1)); - } - return pushresult(L, aux_close(L), NULL); -} - - -static int io_gc (lua_State *L) { - FILE **f = topfile(L, 1); - if (*f != NULL) /* ignore closed files */ - aux_close(L); - return 0; -} - - -static int io_tostring (lua_State *L) { - char buff[32]; - FILE **f = topfile(L, 1); - if (*f == NULL) - strcpy(buff, "closed"); - else - sprintf(buff, "%p", lua_touserdata(L, 1)); - lua_pushfstring(L, "file (%s)", buff); - return 1; -} - - -static int io_open (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; -} - - -static int io_popen (lua_State *L) { -#if !USE_POPEN - luaL_error(L, "`popen' not supported"); - return 0; -#else - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - FILE **pf = newfile(L); - *pf = popen(filename, mode); - return (*pf == NULL) ? pushresult(L, 0, filename) : 1; -#endif -} - - -static int io_tmpfile (lua_State *L) { - FILE **pf = newfile(L); - *pf = tmpfile(); - return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; -} - - -static FILE *getiofile (lua_State *L, const char *name) { - lua_pushstring(L, name); - lua_rawget(L, lua_upvalueindex(1)); - return tofile(L, -1); -} - - -static int g_iofile (lua_State *L, const char *name, const char *mode) { - if (!lua_isnoneornil(L, 1)) { - const char *filename = lua_tostring(L, 1); - lua_pushstring(L, name); - if (filename) { - FILE **pf = newfile(L); - *pf = fopen(filename, mode); - if (*pf == NULL) { - lua_pushfstring(L, "%s: %s", filename, strerror(errno)); - luaL_argerror(L, 1, lua_tostring(L, -1)); - } - } - else { - tofile(L, 1); /* check that it's a valid file handle */ - lua_pushvalue(L, 1); - } - lua_rawset(L, lua_upvalueindex(1)); - } - /* return current value */ - lua_pushstring(L, name); - lua_rawget(L, lua_upvalueindex(1)); - return 1; -} - - -static int io_input (lua_State *L) { - return g_iofile(L, IO_INPUT, "r"); -} - - -static int io_output (lua_State *L) { - return g_iofile(L, IO_OUTPUT, "w"); -} - - -static int io_readline (lua_State *L); - - -static void aux_lines (lua_State *L, int idx, int close) { - lua_pushliteral(L, FILEHANDLE); - lua_rawget(L, LUA_REGISTRYINDEX); - lua_pushvalue(L, idx); - lua_pushboolean(L, close); /* close/not close file when finished */ - lua_pushcclosure(L, io_readline, 3); -} - - -static int f_lines (lua_State *L) { - tofile(L, 1); /* check that it's a valid file handle */ - aux_lines(L, 1, 0); - return 1; -} - - -static int io_lines (lua_State *L) { - if (lua_isnoneornil(L, 1)) { /* no arguments? */ - lua_pushstring(L, IO_INPUT); - lua_rawget(L, lua_upvalueindex(1)); /* will iterate over default input */ - return f_lines(L); - } - else { - const char *filename = luaL_checkstring(L, 1); - FILE **pf = newfile(L); - *pf = fopen(filename, "r"); - luaL_argcheck(L, *pf, 1, strerror(errno)); - aux_lines(L, lua_gettop(L), 1); - return 1; - } -} - - -/* -** {====================================================== -** READ -** ======================================================= -*/ - - -static int read_number (lua_State *L, FILE *f) { - lua_Number d; - if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { - lua_pushnumber(L, d); - return 1; - } - else return 0; /* read fails */ -} - - -static int test_eof (lua_State *L, FILE *f) { - int c = getc(f); - ungetc(c, f); - lua_pushlstring(L, NULL, 0); - return (c != EOF); -} - - -static int read_line (lua_State *L, FILE *f) { - luaL_Buffer b; - luaL_buffinit(L, &b); - for (;;) { - size_t l; - char *p = luaL_prepbuffer(&b); - if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ - luaL_pushresult(&b); /* close buffer */ - return (lua_strlen(L, -1) > 0); /* check whether read something */ - } - l = strlen(p); - if (p[l-1] != '\n') - luaL_addsize(&b, l); - else { - luaL_addsize(&b, l - 1); /* do not include `eol' */ - luaL_pushresult(&b); /* close buffer */ - return 1; /* read at least an `eol' */ - } - } -} - - -static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t rlen; /* how much to read */ - size_t nr; /* number of chars actually read */ - luaL_Buffer b; - luaL_buffinit(L, &b); - rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ - do { - char *p = luaL_prepbuffer(&b); - if (rlen > n) rlen = n; /* cannot read more than asked */ - nr = fread(p, sizeof(char), rlen, f); - luaL_addsize(&b, nr); - n -= nr; /* still have to read `n' chars */ - } while (n > 0 && nr == rlen); /* until end of count or eof */ - luaL_pushresult(&b); /* close buffer */ - return (n == 0 || lua_strlen(L, -1) > 0); -} - - -static int g_read (lua_State *L, FILE *f, int first) { - int nargs = lua_gettop(L) - 1; - int success; - int n; - if (nargs == 0) { /* no arguments? */ - success = read_line(L, f); - n = first+1; /* to return 1 result */ - } - else { /* ensure stack space for all results and for auxlib's buffer */ - luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); - success = 1; - for (n = first; nargs-- && success; n++) { - if (lua_type(L, n) == LUA_TNUMBER) { - size_t l = (size_t)lua_tonumber(L, n); - success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); - } - else { - const char *p = lua_tostring(L, n); - luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); - switch (p[1]) { - case 'n': /* number */ - success = read_number(L, f); - break; - case 'l': /* line */ - success = read_line(L, f); - break; - case 'a': /* file */ - read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ - success = 1; /* always success */ - break; - case 'w': /* word */ - return luaL_error(L, "obsolete option `*w' to `read'"); - default: - return luaL_argerror(L, n, "invalid format"); - } - } - } - } - if (!success) { - lua_pop(L, 1); /* remove last result */ - lua_pushnil(L); /* push nil instead */ - } - return n - first; -} - - -static int io_read (lua_State *L) { - return g_read(L, getiofile(L, IO_INPUT), 1); -} - - -static int f_read (lua_State *L) { - return g_read(L, tofile(L, 1), 2); -} - - -static int io_readline (lua_State *L) { - FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(2)); - if (f == NULL) /* file is already closed? */ - luaL_error(L, "file is already closed"); - if (read_line(L, f)) return 1; - else { /* EOF */ - if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ - lua_settop(L, 0); - lua_pushvalue(L, lua_upvalueindex(2)); - aux_close(L); /* close it */ - } - return 0; - } -} - -/* }====================================================== */ - - -static int g_write (lua_State *L, FILE *f, int arg) { - int nargs = lua_gettop(L) - 1; - int status = 1; - for (; nargs--; arg++) { - if (lua_type(L, arg) == LUA_TNUMBER) { - /* optimization: could be done exactly as for strings */ - status = status && - fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; - } - else { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - status = status && (fwrite(s, sizeof(char), l, f) == l); - } - } - return pushresult(L, status, NULL); -} - - -static int io_write (lua_State *L) { - return g_write(L, getiofile(L, IO_OUTPUT), 1); -} - - -static int f_write (lua_State *L) { - return g_write(L, tofile(L, 1), 2); -} - - -static int f_seek (lua_State *L) { - static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; - static const char *const modenames[] = {"set", "cur", "end", NULL}; - FILE *f = tofile(L, 1); - int op = luaL_findstring(luaL_optstring(L, 2, "cur"), modenames); - long offset = luaL_optlong(L, 3, 0); - luaL_argcheck(L, op != -1, 2, "invalid mode"); - op = fseek(f, offset, mode[op]); - if (op) - return pushresult(L, 0, NULL); /* error */ - else { - lua_pushnumber(L, ftell(f)); - return 1; - } -} - - -static int io_flush (lua_State *L) { - return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); -} - - -static int f_flush (lua_State *L) { - return pushresult(L, fflush(tofile(L, 1)) == 0, NULL); -} - - -static const luaL_reg iolib[] = { - {"input", io_input}, - {"output", io_output}, - {"lines", io_lines}, - {"close", io_close}, - {"flush", io_flush}, - {"open", io_open}, - {"popen", io_popen}, - {"read", io_read}, - {"tmpfile", io_tmpfile}, - {"type", io_type}, - {"write", io_write}, - {NULL, NULL} -}; - - -static const luaL_reg flib[] = { - {"flush", f_flush}, - {"read", f_read}, - {"lines", f_lines}, - {"seek", f_seek}, - {"write", f_write}, - {"close", io_close}, - {"__gc", io_gc}, - {"__tostring", io_tostring}, - {NULL, NULL} -}; - - -static void createmeta (lua_State *L) { - luaL_newmetatable(L, FILEHANDLE); /* create new metatable for file handles */ - /* file methods */ - lua_pushliteral(L, "__index"); - lua_pushvalue(L, -2); /* push metatable */ - lua_rawset(L, -3); /* metatable.__index = metatable */ - luaL_openlib(L, NULL, flib, 0); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Other O.S. Operations -** ======================================================= -*/ - -static int io_execute (lua_State *L) { - lua_pushnumber(L, system(luaL_checkstring(L, 1))); - return 1; -} - - -static int io_remove (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - return pushresult(L, remove(filename) == 0, filename); -} - - -static int io_rename (lua_State *L) { - const char *fromname = luaL_checkstring(L, 1); - const char *toname = luaL_checkstring(L, 2); - return pushresult(L, rename(fromname, toname) == 0, fromname); -} - - -static int io_tmpname (lua_State *L) { -#if !USE_TMPNAME - luaL_error(L, "`tmpname' not supported"); - return 0; -#else - char buff[L_tmpnam]; - if (tmpnam(buff) != buff) - return luaL_error(L, "unable to generate a unique filename in `tmpname'"); - lua_pushstring(L, buff); - return 1; -#endif -} - - -static int io_getenv (lua_State *L) { - lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ - return 1; -} - - -static int io_clock (lua_State *L) { - lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); - return 1; -} - - -/* -** {====================================================== -** Time/Date operations -** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, -** wday=%w+1, yday=%j, isdst=? } -** ======================================================= -*/ - -static void setfield (lua_State *L, const char *key, int value) { - lua_pushstring(L, key); - lua_pushnumber(L, value); - lua_rawset(L, -3); -} - -static void setboolfield (lua_State *L, const char *key, int value) { - lua_pushstring(L, key); - lua_pushboolean(L, value); - lua_rawset(L, -3); -} - -static int getboolfield (lua_State *L, const char *key) { - int res; - lua_pushstring(L, key); - lua_gettable(L, -2); - res = lua_toboolean(L, -1); - lua_pop(L, 1); - return res; -} - - -static int getfield (lua_State *L, const char *key, int d) { - int res; - lua_pushstring(L, key); - lua_gettable(L, -2); - if (lua_isnumber(L, -1)) - res = (int)(lua_tonumber(L, -1)); - else { - if (d == -2) - return luaL_error(L, "field `%s' missing in date table", key); - res = d; - } - lua_pop(L, 1); - return res; -} - - -static int io_date (lua_State *L) { - const char *s = luaL_optstring(L, 1, "%c"); - time_t t = (time_t)(luaL_optnumber(L, 2, -1)); - struct tm *stm; - if (t == (time_t)(-1)) /* no time given? */ - t = time(NULL); /* use current time */ - if (*s == '!') { /* UTC? */ - stm = gmtime(&t); - s++; /* skip `!' */ - } - else - stm = localtime(&t); - if (stm == NULL) /* invalid date? */ - lua_pushnil(L); - else if (strcmp(s, "*t") == 0) { - lua_newtable(L); - setfield(L, "sec", stm->tm_sec); - setfield(L, "min", stm->tm_min); - setfield(L, "hour", stm->tm_hour); - setfield(L, "day", stm->tm_mday); - setfield(L, "month", stm->tm_mon+1); - setfield(L, "year", stm->tm_year+1900); - setfield(L, "wday", stm->tm_wday+1); - setfield(L, "yday", stm->tm_yday+1); - setboolfield(L, "isdst", stm->tm_isdst); - } - else { - char b[256]; - if (strftime(b, sizeof(b), s, stm)) - lua_pushstring(L, b); - else - return luaL_error(L, "`date' format too long"); - } - return 1; -} - - -static int io_time (lua_State *L) { - if (lua_isnoneornil(L, 1)) /* called without args? */ - lua_pushnumber(L, time(NULL)); /* return current time */ - else { - time_t t; - struct tm ts; - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 1); /* make sure table is at the top */ - ts.tm_sec = getfield(L, "sec", 0); - ts.tm_min = getfield(L, "min", 0); - ts.tm_hour = getfield(L, "hour", 12); - ts.tm_mday = getfield(L, "day", -2); - ts.tm_mon = getfield(L, "month", -2) - 1; - ts.tm_year = getfield(L, "year", -2) - 1900; - ts.tm_isdst = getboolfield(L, "isdst"); - t = mktime(&ts); - if (t == (time_t)(-1)) - lua_pushnil(L); - else - lua_pushnumber(L, t); - } - return 1; -} - - -static int io_difftime (lua_State *L) { - lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), - (time_t)(luaL_optnumber(L, 2, 0)))); - return 1; -} - -/* }====================================================== */ - - -static int io_setloc (lua_State *L) { - static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, - LC_NUMERIC, LC_TIME}; - static const char *const catnames[] = {"all", "collate", "ctype", "monetary", - "numeric", "time", NULL}; - const char *l = lua_tostring(L, 1); - int op = luaL_findstring(luaL_optstring(L, 2, "all"), catnames); - luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected"); - luaL_argcheck(L, op != -1, 2, "invalid option"); - lua_pushstring(L, setlocale(cat[op], l)); - return 1; -} - - -static int io_exit (lua_State *L) { - exit(luaL_optint(L, 1, EXIT_SUCCESS)); - return 0; /* to avoid warnings */ -} - -static const luaL_reg syslib[] = { - {"clock", io_clock}, - {"date", io_date}, - {"difftime", io_difftime}, - {"execute", io_execute}, - {"exit", io_exit}, - {"getenv", io_getenv}, - {"remove", io_remove}, - {"rename", io_rename}, - {"setlocale", io_setloc}, - {"time", io_time}, - {"tmpname", io_tmpname}, - {NULL, NULL} -}; - -/* }====================================================== */ - - - -LUALIB_API int luaopen_io (lua_State *L) { - luaL_openlib(L, LUA_OSLIBNAME, syslib, 0); - createmeta(L); - lua_pushvalue(L, -1); - luaL_openlib(L, LUA_IOLIBNAME, iolib, 1); - /* put predefined file handles into `io' table */ - registerfile(L, stdin, "stdin", IO_INPUT); - registerfile(L, stdout, "stdout", IO_OUTPUT); - registerfile(L, stderr, "stderr", NULL); - return 1; -} - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include +#include +#include +#include +#include +#include + +#define liolib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +/* +** by default, gcc does not get `tmpname' +*/ +#ifndef USE_TMPNAME +#ifdef __GNUC__ +#define USE_TMPNAME 0 +#else +#define USE_TMPNAME 1 +#endif +#endif + + +/* +** by default, posix systems get `popen' +*/ +#ifndef USE_POPEN +#ifdef _POSIX_C_SOURCE +#if _POSIX_C_SOURCE >= 2 +#define USE_POPEN 1 +#endif +#endif +#endif + +#ifndef USE_POPEN +#define USE_POPEN 0 +#endif + + + + +/* +** {====================================================== +** FILE Operations +** ======================================================= +*/ + + +#if !USE_POPEN +#define pclose(f) (-1) +#endif + + +#define FILEHANDLE "FILE*" + +#define IO_INPUT "_input" +#define IO_OUTPUT "_output" + + +static int pushresult (lua_State *L, int i, const char *filename) { + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + else + lua_pushfstring(L, "%s", strerror(errno)); + lua_pushnumber(L, errno); + return 3; + } +} + + +static FILE **topfile (lua_State *L, int findex) { + FILE **f = (FILE **)luaL_checkudata(L, findex, FILEHANDLE); + if (f == NULL) luaL_argerror(L, findex, "bad file"); + return f; +} + + +static int io_type (lua_State *L) { + FILE **f = (FILE **)luaL_checkudata(L, 1, FILEHANDLE); + if (f == NULL) lua_pushnil(L); + else if (*f == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L, int findex) { + FILE **f = topfile(L, findex); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** assumes that top of the stack is the `io' library, and next is +** the `io' metatable +*/ +static void registerfile (lua_State *L, FILE *f, const char *name, + const char *impname) { + lua_pushstring(L, name); + *newfile(L) = f; + if (impname) { + lua_pushstring(L, impname); + lua_pushvalue(L, -2); + lua_settable(L, -6); /* metatable[impname] = file */ + } + lua_settable(L, -3); /* io[name] = file */ +} + + +static int aux_close (lua_State *L) { + FILE *f = tofile(L, 1); + if (f == stdin || f == stdout || f == stderr) + return 0; /* file cannot be closed */ + else { + int ok = (pclose(f) != -1) || (fclose(f) == 0); + if (ok) + *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ + return ok; + } +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) { + lua_pushstring(L, IO_OUTPUT); + lua_rawget(L, lua_upvalueindex(1)); + } + return pushresult(L, aux_close(L), NULL); +} + + +static int io_gc (lua_State *L) { + FILE **f = topfile(L, 1); + if (*f != NULL) /* ignore closed files */ + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + char buff[32]; + FILE **f = topfile(L, 1); + if (*f == NULL) + strcpy(buff, "closed"); + else + sprintf(buff, "%p", lua_touserdata(L, 1)); + lua_pushfstring(L, "file (%s)", buff); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_popen (lua_State *L) { +#if !USE_POPEN + luaL_error(L, "`popen' not supported"); + return 0; +#else + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = popen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +#endif +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, const char *name) { + lua_pushstring(L, name); + lua_rawget(L, lua_upvalueindex(1)); + return tofile(L, -1); +} + + +static int g_iofile (lua_State *L, const char *name, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + lua_pushstring(L, name); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, 1, lua_tostring(L, -1)); + } + } + else { + tofile(L, 1); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawset(L, lua_upvalueindex(1)); + } + /* return current value */ + lua_pushstring(L, name); + lua_rawget(L, lua_upvalueindex(1)); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int close) { + lua_pushliteral(L, FILEHANDLE); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushvalue(L, idx); + lua_pushboolean(L, close); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 3); +} + + +static int f_lines (lua_State *L) { + tofile(L, 1); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + lua_pushstring(L, IO_INPUT); + lua_rawget(L, lua_upvalueindex(1)); /* will iterate over default input */ + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + luaL_argcheck(L, *pf, 1, strerror(errno)); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_strlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_strlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tonumber(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + case 'w': /* word */ + return luaL_error(L, "obsolete option `*w' to `read'"); + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L, 1), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(2)); + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + if (read_line(L, f)) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(2)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L, 1), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L, 1); + int op = luaL_findstring(luaL_optstring(L, 2, "cur"), modenames); + long offset = luaL_optlong(L, 3, 0); + luaL_argcheck(L, op != -1, 2, "invalid mode"); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushnumber(L, ftell(f)); + return 1; + } +} + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L, 1)) == 0, NULL); +} + + +static const luaL_reg iolib[] = { + {"input", io_input}, + {"output", io_output}, + {"lines", io_lines}, + {"close", io_close}, + {"flush", io_flush}, + {"open", io_open}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_reg flib[] = { + {"flush", f_flush}, + {"read", f_read}, + {"lines", f_lines}, + {"seek", f_seek}, + {"write", f_write}, + {"close", io_close}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, FILEHANDLE); /* create new metatable for file handles */ + /* file methods */ + lua_pushliteral(L, "__index"); + lua_pushvalue(L, -2); /* push metatable */ + lua_rawset(L, -3); /* metatable.__index = metatable */ + luaL_openlib(L, NULL, flib, 0); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Other O.S. Operations +** ======================================================= +*/ + +static int io_execute (lua_State *L) { + lua_pushnumber(L, system(luaL_checkstring(L, 1))); + return 1; +} + + +static int io_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return pushresult(L, remove(filename) == 0, filename); +} + + +static int io_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int io_tmpname (lua_State *L) { +#if !USE_TMPNAME + luaL_error(L, "`tmpname' not supported"); + return 0; +#else + char buff[L_tmpnam]; + if (tmpnam(buff) != buff) + return luaL_error(L, "unable to generate a unique filename in `tmpname'"); + lua_pushstring(L, buff); + return 1; +#endif +} + + +static int io_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int io_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushstring(L, key); + lua_pushnumber(L, value); + lua_rawset(L, -3); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + lua_pushstring(L, key); + lua_pushboolean(L, value); + lua_rawset(L, -3); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_pushstring(L, key); + lua_gettable(L, -2); + res = lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_pushstring(L, key); + lua_gettable(L, -2); + if (lua_isnumber(L, -1)) + res = (int)(lua_tonumber(L, -1)); + else { + if (d == -2) + return luaL_error(L, "field `%s' missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int io_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = (time_t)(luaL_optnumber(L, 2, -1)); + struct tm *stm; + if (t == (time_t)(-1)) /* no time given? */ + t = time(NULL); /* use current time */ + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_newtable(L); + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char b[256]; + if (strftime(b, sizeof(b), s, stm)) + lua_pushstring(L, b); + else + return luaL_error(L, "`date' format too long"); + } + return 1; +} + + +static int io_time (lua_State *L) { + if (lua_isnoneornil(L, 1)) /* called without args? */ + lua_pushnumber(L, time(NULL)); /* return current time */ + else { + time_t t; + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -2); + ts.tm_mon = getfield(L, "month", -2) - 1; + ts.tm_year = getfield(L, "year", -2) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, t); + } + return 1; +} + + +static int io_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int io_setloc (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = lua_tostring(L, 1); + int op = luaL_findstring(luaL_optstring(L, 2, "all"), catnames); + luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected"); + luaL_argcheck(L, op != -1, 2, "invalid option"); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int io_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); + return 0; /* to avoid warnings */ +} + +static const luaL_reg syslib[] = { + {"clock", io_clock}, + {"date", io_date}, + {"difftime", io_difftime}, + {"execute", io_execute}, + {"exit", io_exit}, + {"getenv", io_getenv}, + {"remove", io_remove}, + {"rename", io_rename}, + {"setlocale", io_setloc}, + {"time", io_time}, + {"tmpname", io_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_io (lua_State *L) { + luaL_openlib(L, LUA_OSLIBNAME, syslib, 0); + createmeta(L); + lua_pushvalue(L, -1); + luaL_openlib(L, LUA_IOLIBNAME, iolib, 1); + /* put predefined file handles into `io' table */ + registerfile(L, stdin, "stdin", IO_INPUT); + registerfile(L, stdout, "stdout", IO_OUTPUT); + registerfile(L, stderr, "stderr", NULL); + return 1; +} + diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lmathlib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lmathlib.c index 93eb3cba9..266cc707f 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lmathlib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lmathlib.c @@ -1,256 +1,256 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include - -#define lmathlib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -#undef PI -#define PI (3.14159265358979323846) -#define RADIANS_PER_DEGREE (PI/180.0) - - - -/* -** If you want Lua to operate in degrees (instead of radians), -** define USE_DEGREES -*/ -#ifdef USE_DEGREES -#define FROMRAD(a) ((a)/RADIANS_PER_DEGREE) -#define TORAD(a) ((a)*RADIANS_PER_DEGREE) -#else -#define FROMRAD(a) (a) -#define TORAD(a) (a) -#endif - - -static int math_abs (lua_State *L) { - lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); - return 1; -} - -static int math_sin (lua_State *L) { - lua_pushnumber(L, sin(TORAD(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_cos (lua_State *L) { - lua_pushnumber(L, cos(TORAD(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_tan (lua_State *L) { - lua_pushnumber(L, tan(TORAD(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_asin (lua_State *L) { - lua_pushnumber(L, FROMRAD(asin(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_acos (lua_State *L) { - lua_pushnumber(L, FROMRAD(acos(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_atan (lua_State *L) { - lua_pushnumber(L, FROMRAD(atan(luaL_checknumber(L, 1)))); - return 1; -} - -static int math_atan2 (lua_State *L) { - lua_pushnumber(L, FROMRAD(atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)))); - return 1; -} - -static int math_ceil (lua_State *L) { - lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); - return 1; -} - -static int math_floor (lua_State *L) { - lua_pushnumber(L, floor(luaL_checknumber(L, 1))); - return 1; -} - -static int math_mod (lua_State *L) { - lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); - return 1; -} - -static int math_sqrt (lua_State *L) { - lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); - return 1; -} - -static int math_pow (lua_State *L) { - lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); - return 1; -} - -static int math_log (lua_State *L) { - lua_pushnumber(L, log(luaL_checknumber(L, 1))); - return 1; -} - -static int math_log10 (lua_State *L) { - lua_pushnumber(L, log10(luaL_checknumber(L, 1))); - return 1; -} - -static int math_exp (lua_State *L) { - lua_pushnumber(L, exp(luaL_checknumber(L, 1))); - return 1; -} - -static int math_deg (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); - return 1; -} - -static int math_rad (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); - return 1; -} - -static int math_frexp (lua_State *L) { - int e; - lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); - lua_pushnumber(L, e); - return 2; -} - -static int math_ldexp (lua_State *L) { - lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); - return 1; -} - - - -static int math_min (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - lua_Number dmin = luaL_checknumber(L, 1); - int i; - for (i=2; i<=n; i++) { - lua_Number d = luaL_checknumber(L, i); - if (d < dmin) - dmin = d; - } - lua_pushnumber(L, dmin); - return 1; -} - - -static int math_max (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - lua_Number dmax = luaL_checknumber(L, 1); - int i; - for (i=2; i<=n; i++) { - lua_Number d = luaL_checknumber(L, i); - if (d > dmax) - dmax = d; - } - lua_pushnumber(L, dmax); - return 1; -} - - -static int math_random (lua_State *L) { - /* the `%' avoids the (rare) case of r==1, and is needed also because on - some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ - lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; - switch (lua_gettop(L)) { /* check number of arguments */ - case 0: { /* no arguments */ - lua_pushnumber(L, r); /* Number between 0 and 1 */ - break; - } - case 1: { /* only upper limit */ - int u = luaL_checkint(L, 1); - luaL_argcheck(L, 1<=u, 1, "interval is empty"); - lua_pushnumber(L, (int)floor(r*u)+1); /* int between 1 and `u' */ - break; - } - case 2: { /* lower and upper limits */ - int l = luaL_checkint(L, 1); - int u = luaL_checkint(L, 2); - luaL_argcheck(L, l<=u, 2, "interval is empty"); - lua_pushnumber(L, (int)floor(r*(u-l+1))+l); /* int between `l' and `u' */ - break; - } - default: return luaL_error(L, "wrong number of arguments"); - } - return 1; -} - - -static int math_randomseed (lua_State *L) { - srand(luaL_checkint(L, 1)); - return 0; -} - - -static const luaL_reg mathlib[] = { - {"abs", math_abs}, - {"sin", math_sin}, - {"cos", math_cos}, - {"tan", math_tan}, - {"asin", math_asin}, - {"acos", math_acos}, - {"atan", math_atan}, - {"atan2", math_atan2}, - {"ceil", math_ceil}, - {"floor", math_floor}, - {"mod", math_mod}, - {"frexp", math_frexp}, - {"ldexp", math_ldexp}, - {"sqrt", math_sqrt}, - {"min", math_min}, - {"max", math_max}, - {"log", math_log}, - {"log10", math_log10}, - {"exp", math_exp}, - {"deg", math_deg}, - {"pow", math_pow}, - {"rad", math_rad}, - {"random", math_random}, - {"randomseed", math_randomseed}, - {NULL, NULL} -}; - - -/* -** Open math library -*/ -LUALIB_API int luaopen_math (lua_State *L) { - luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); - lua_pushliteral(L, "pi"); - lua_pushnumber(L, PI); - lua_settable(L, -3); - lua_pushliteral(L, "__pow"); - lua_pushcfunction(L, math_pow); - lua_settable(L, LUA_GLOBALSINDEX); - return 1; -} - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include +#include + +#define lmathlib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +/* +** If you want Lua to operate in degrees (instead of radians), +** define USE_DEGREES +*/ +#ifdef USE_DEGREES +#define FROMRAD(a) ((a)/RADIANS_PER_DEGREE) +#define TORAD(a) ((a)*RADIANS_PER_DEGREE) +#else +#define FROMRAD(a) (a) +#define TORAD(a) (a) +#endif + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(TORAD(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(TORAD(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(TORAD(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, FROMRAD(asin(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, FROMRAD(acos(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, FROMRAD(atan(luaL_checknumber(L, 1)))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, FROMRAD(atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_mod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushnumber(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, (int)floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, (int)floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_reg mathlib[] = { + {"abs", math_abs}, + {"sin", math_sin}, + {"cos", math_cos}, + {"tan", math_tan}, + {"asin", math_asin}, + {"acos", math_acos}, + {"atan", math_atan}, + {"atan2", math_atan2}, + {"ceil", math_ceil}, + {"floor", math_floor}, + {"mod", math_mod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"sqrt", math_sqrt}, + {"min", math_min}, + {"max", math_max}, + {"log", math_log}, + {"log10", math_log10}, + {"exp", math_exp}, + {"deg", math_deg}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); + lua_pushliteral(L, "pi"); + lua_pushnumber(L, PI); + lua_settable(L, -3); + lua_pushliteral(L, "__pow"); + lua_pushcfunction(L, math_pow); + lua_settable(L, LUA_GLOBALSINDEX); + return 1; +} + diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/loadlib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/loadlib.c index 6f4b8bb42..e28d6018f 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/loadlib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/loadlib.c @@ -1,205 +1,205 @@ -/* -** $Id: loadlib.c,v 1.1 2005/10/25 09:41:32 vizerie Exp $ -** Dynamic library loader for Lua -** See Copyright Notice in lua.h -* -* This Lua library exports a single function, called loadlib, which is -* called from Lua as loadlib(lib,init), where lib is the full name of the -* library to be loaded (including the complete path) and init is the name -* of a function to be called after the library is loaded. Typically, this -* function will register other functions, thus making the complete library -* available to Lua. The init function is *not* automatically called by -* loadlib. Instead, loadlib returns the init function as a Lua function -* that the client can call when it thinks is appropriate. In the case of -* errors, loadlib returns nil and two strings describing the error. -* The first string is supplied by the operating system; it should be -* informative and useful for error messages. The second string is "open", -* "init", or "absent" to identify the error and is meant to be used for -* making decisions without having to look into the first string (whose -* format is system-dependent). -* -* This module contains an implementation of loadlib for Unix systems that -* have dlfcn, an implementation for Windows, and a stub for other systems. -* See the list at the end of this file for some links to available -* implementations of dlfcn and interfaces to other native dynamic loaders -* on top of which loadlib could be implemented. -* -*/ - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - - -#undef LOADLIB - - -#ifdef USE_DLOPEN -#define LOADLIB -/* -* This is an implementation of loadlib based on the dlfcn interface. -* The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, -* NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least -* as an emulation layer on top of native functions. -*/ - -#include - -static int loadlib(lua_State *L) -{ - const char *path=luaL_checkstring(L,1); - const char *init=luaL_checkstring(L,2); - void *lib=dlopen(path,RTLD_NOW); - if (lib!=NULL) - { - lua_CFunction f=(lua_CFunction) dlsym(lib,init); - if (f!=NULL) - { - lua_pushlightuserdata(L,lib); - lua_pushcclosure(L,f,1); - return 1; - } - } - /* else return appropriate error messages */ - lua_pushnil(L); - lua_pushstring(L,dlerror()); - lua_pushstring(L,(lib!=NULL) ? "init" : "open"); - if (lib!=NULL) dlclose(lib); - return 3; -} - -#endif - - - -/* -** In Windows, default is to use dll; otherwise, default is not to use dll -*/ -#ifndef USE_DLL -#ifdef _WIN32 -#define USE_DLL 1 -#else -#define USE_DLL 0 -#endif -#endif - - -#if USE_DLL -#define LOADLIB -/* -* This is an implementation of loadlib for Windows using native functions. -*/ - -#include - -static void pusherror(lua_State *L) -{ - int error=GetLastError(); - char buffer[128]; - if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - 0, error, 0, buffer, sizeof(buffer), 0)) - lua_pushstring(L,buffer); - else - lua_pushfstring(L,"system error %d\n",error); -} - -static int loadlib(lua_State *L) -{ - const char *path=luaL_checkstring(L,1); - const char *init=luaL_checkstring(L,2); - HINSTANCE lib=LoadLibrary(path); - if (lib!=NULL) - { - lua_CFunction f=(lua_CFunction) GetProcAddress(lib,init); - if (f!=NULL) - { - lua_pushlightuserdata(L,lib); - lua_pushcclosure(L,f,1); - return 1; - } - } - lua_pushnil(L); - pusherror(L); - lua_pushstring(L,(lib!=NULL) ? "init" : "open"); - if (lib!=NULL) FreeLibrary(lib); - return 3; -} - -#endif - - - -#ifndef LOADLIB -/* Fallback for other systems */ - -/* -** Those systems support dlopen, so they should have defined USE_DLOPEN. -** The default (no)implementation gives them a special error message. -*/ -#ifdef linux -#define LOADLIB -#endif - -#ifdef sun -#define LOADLIB -#endif - -#ifdef sgi -#define LOADLIB -#endif - -#ifdef BSD -#define LOADLIB -#endif - -#ifdef _WIN32 -#define LOADLIB -#endif - -#ifdef LOADLIB -#undef LOADLIB -#define LOADLIB "`loadlib' not installed (check your Lua configuration)" -#else -#define LOADLIB "`loadlib' not supported" -#endif - -static int loadlib(lua_State *L) -{ - lua_pushnil(L); - lua_pushliteral(L,LOADLIB); - lua_pushliteral(L,"absent"); - return 3; -} -#endif - -LUALIB_API int luaopen_loadlib (lua_State *L) -{ - lua_register(L,"loadlib",loadlib); - return 0; -} - -/* -* Here are some links to available implementations of dlfcn and -* interfaces to other native dynamic loaders on top of which loadlib -* could be implemented. Please send contributions and corrections to us. -* -* AIX -* Starting with AIX 4.2, dlfcn is included in the base OS. -* There is also an emulation package available. -* http://www.faqs.org/faqs/aix-faq/part4/section-21.html -* -* HPUX -* HPUX 11 has dlfcn. For HPUX 10 use shl_*. -* http://www.geda.seul.org/mailinglist/geda-dev37/msg00094.html -* http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html -* -* Macintosh, Windows -* http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html -* -* Mac OS X/Darwin -* http://www.opendarwin.org/projects/dlcompat/ -* -* GLIB has wrapper code for BeOS, OS2, Unix and Windows -* http://cvs.gnome.org/lxr/source/glib/gmodule/ -* -*/ +/* +** $Id: loadlib.c,v 1.1 2005/10/25 09:41:32 vizerie Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +* +* This Lua library exports a single function, called loadlib, which is +* called from Lua as loadlib(lib,init), where lib is the full name of the +* library to be loaded (including the complete path) and init is the name +* of a function to be called after the library is loaded. Typically, this +* function will register other functions, thus making the complete library +* available to Lua. The init function is *not* automatically called by +* loadlib. Instead, loadlib returns the init function as a Lua function +* that the client can call when it thinks is appropriate. In the case of +* errors, loadlib returns nil and two strings describing the error. +* The first string is supplied by the operating system; it should be +* informative and useful for error messages. The second string is "open", +* "init", or "absent" to identify the error and is meant to be used for +* making decisions without having to look into the first string (whose +* format is system-dependent). +* +* This module contains an implementation of loadlib for Unix systems that +* have dlfcn, an implementation for Windows, and a stub for other systems. +* See the list at the end of this file for some links to available +* implementations of dlfcn and interfaces to other native dynamic loaders +* on top of which loadlib could be implemented. +* +*/ + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + + +#undef LOADLIB + + +#ifdef USE_DLOPEN +#define LOADLIB +/* +* This is an implementation of loadlib based on the dlfcn interface. +* The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +* NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +* as an emulation layer on top of native functions. +*/ + +#include + +static int loadlib(lua_State *L) +{ + const char *path=luaL_checkstring(L,1); + const char *init=luaL_checkstring(L,2); + void *lib=dlopen(path,RTLD_NOW); + if (lib!=NULL) + { + lua_CFunction f=(lua_CFunction) dlsym(lib,init); + if (f!=NULL) + { + lua_pushlightuserdata(L,lib); + lua_pushcclosure(L,f,1); + return 1; + } + } + /* else return appropriate error messages */ + lua_pushnil(L); + lua_pushstring(L,dlerror()); + lua_pushstring(L,(lib!=NULL) ? "init" : "open"); + if (lib!=NULL) dlclose(lib); + return 3; +} + +#endif + + + +/* +** In Windows, default is to use dll; otherwise, default is not to use dll +*/ +#ifndef USE_DLL +#ifdef _WIN32 +#define USE_DLL 1 +#else +#define USE_DLL 0 +#endif +#endif + + +#if USE_DLL +#define LOADLIB +/* +* This is an implementation of loadlib for Windows using native functions. +*/ + +#include + +static void pusherror(lua_State *L) +{ + int error=GetLastError(); + char buffer[128]; + if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + 0, error, 0, buffer, sizeof(buffer), 0)) + lua_pushstring(L,buffer); + else + lua_pushfstring(L,"system error %d\n",error); +} + +static int loadlib(lua_State *L) +{ + const char *path=luaL_checkstring(L,1); + const char *init=luaL_checkstring(L,2); + HINSTANCE lib=LoadLibrary(path); + if (lib!=NULL) + { + lua_CFunction f=(lua_CFunction) GetProcAddress(lib,init); + if (f!=NULL) + { + lua_pushlightuserdata(L,lib); + lua_pushcclosure(L,f,1); + return 1; + } + } + lua_pushnil(L); + pusherror(L); + lua_pushstring(L,(lib!=NULL) ? "init" : "open"); + if (lib!=NULL) FreeLibrary(lib); + return 3; +} + +#endif + + + +#ifndef LOADLIB +/* Fallback for other systems */ + +/* +** Those systems support dlopen, so they should have defined USE_DLOPEN. +** The default (no)implementation gives them a special error message. +*/ +#ifdef linux +#define LOADLIB +#endif + +#ifdef sun +#define LOADLIB +#endif + +#ifdef sgi +#define LOADLIB +#endif + +#ifdef BSD +#define LOADLIB +#endif + +#ifdef _WIN32 +#define LOADLIB +#endif + +#ifdef LOADLIB +#undef LOADLIB +#define LOADLIB "`loadlib' not installed (check your Lua configuration)" +#else +#define LOADLIB "`loadlib' not supported" +#endif + +static int loadlib(lua_State *L) +{ + lua_pushnil(L); + lua_pushliteral(L,LOADLIB); + lua_pushliteral(L,"absent"); + return 3; +} +#endif + +LUALIB_API int luaopen_loadlib (lua_State *L) +{ + lua_register(L,"loadlib",loadlib); + return 0; +} + +/* +* Here are some links to available implementations of dlfcn and +* interfaces to other native dynamic loaders on top of which loadlib +* could be implemented. Please send contributions and corrections to us. +* +* AIX +* Starting with AIX 4.2, dlfcn is included in the base OS. +* There is also an emulation package available. +* http://www.faqs.org/faqs/aix-faq/part4/section-21.html +* +* HPUX +* HPUX 11 has dlfcn. For HPUX 10 use shl_*. +* http://www.geda.seul.org/mailinglist/geda-dev37/msg00094.html +* http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html +* +* Macintosh, Windows +* http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html +* +* Mac OS X/Darwin +* http://www.opendarwin.org/projects/dlcompat/ +* +* GLIB has wrapper code for BeOS, OS2, Unix and Windows +* http://cvs.gnome.org/lxr/source/glib/gmodule/ +* +*/ diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lstrlib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lstrlib.c index 69e40064b..28cbe0bf4 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lstrlib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/lstrlib.c @@ -1,780 +1,780 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include - -#define lstrlib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -/* macro to `unsign' a character */ -#ifndef uchar -#define uchar(c) ((unsigned char)(c)) -#endif - - -typedef long sint32; /* a signed version for size_t */ - - -static int str_len (lua_State *L) { - size_t l; - luaL_checklstring(L, 1, &l); - lua_pushnumber(L, (lua_Number)l); - return 1; -} - - -static sint32 posrelat (sint32 pos, size_t len) { - /* relative string position: negative means back from end */ - return (pos>=0) ? pos : (sint32)len+pos+1; -} - - -static int str_sub (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - sint32 start = posrelat(luaL_checklong(L, 2), l); - sint32 end = posrelat(luaL_optlong(L, 3, -1), l); - if (start < 1) start = 1; - if (end > (sint32)l) end = (sint32)l; - if (start <= end) - lua_pushlstring(L, s+start-1, end-start+1); - else lua_pushliteral(L, ""); - return 1; -} - - -static int str_lower (lua_State *L) { - size_t l; - size_t i; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - luaL_buffinit(L, &b); - for (i=0; i 0) - luaL_addlstring(&b, s, l); - luaL_pushresult(&b); - return 1; -} - - -static int str_byte (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - sint32 pos = posrelat(luaL_optlong(L, 2, 1), l); - if (pos <= 0 || (size_t)(pos) > l) /* index out of range? */ - return 0; /* no answer */ - lua_pushnumber(L, uchar(s[pos-1])); - return 1; -} - - -static int str_char (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - luaL_Buffer b; - luaL_buffinit(L, &b); - for (i=1; i<=n; i++) { - int c = luaL_checkint(L, i); - luaL_argcheck(L, uchar(c) == c, i, "invalid value"); - luaL_putchar(&b, uchar(c)); - } - luaL_pushresult(&b); - return 1; -} - - -static int writer (lua_State *L, const void* b, size_t size, void* B) { - (void)L; - luaL_addlstring((luaL_Buffer*) B, (const char *)b, size); - return 1; -} - - -static int str_dump (lua_State *L) { - luaL_Buffer b; - luaL_checktype(L, 1, LUA_TFUNCTION); - luaL_buffinit(L,&b); - if (!lua_dump(L, writer, &b)) - luaL_error(L, "unable to dump given function"); - luaL_pushresult(&b); - return 1; -} - - - -/* -** {====================================================== -** PATTERN MATCHING -** ======================================================= -*/ - -#ifndef MAX_CAPTURES -#define MAX_CAPTURES 32 /* arbitrary limit */ -#endif - - -#define CAP_UNFINISHED (-1) -#define CAP_POSITION (-2) - -typedef struct MatchState { - const char *src_init; /* init of source string */ - const char *src_end; /* end (`\0') of source string */ - lua_State *L; - int level; /* total number of captures (finished or unfinished) */ - struct { - const char *init; - sint32 len; - } capture[MAX_CAPTURES]; -} MatchState; - - -#define ESC '%' -#define SPECIALS "^$*+?.([%-" - - -static int check_capture (MatchState *ms, int l) { - l -= '1'; - if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) - return luaL_error(ms->L, "invalid capture index"); - return l; -} - - -static int capture_to_close (MatchState *ms) { - int level = ms->level; - for (level--; level>=0; level--) - if (ms->capture[level].len == CAP_UNFINISHED) return level; - return luaL_error(ms->L, "invalid pattern capture"); -} - - -static const char *luaI_classend (MatchState *ms, const char *p) { - switch (*p++) { - case ESC: { - if (*p == '\0') - luaL_error(ms->L, "malformed pattern (ends with `%')"); - return p+1; - } - case '[': { - if (*p == '^') p++; - do { /* look for a `]' */ - if (*p == '\0') - luaL_error(ms->L, "malformed pattern (missing `]')"); - if (*(p++) == ESC && *p != '\0') - p++; /* skip escapes (e.g. `%]') */ - } while (*p != ']'); - return p+1; - } - default: { - return p; - } - } -} - - -static int match_class (int c, int cl) { - int res; - switch (tolower(cl)) { - case 'a' : res = isalpha(c); break; - case 'c' : res = iscntrl(c); break; - case 'd' : res = isdigit(c); break; - case 'l' : res = islower(c); break; - case 'p' : res = ispunct(c); break; - case 's' : res = isspace(c); break; - case 'u' : res = isupper(c); break; - case 'w' : res = isalnum(c); break; - case 'x' : res = isxdigit(c); break; - case 'z' : res = (c == 0); break; - default: return (cl == c); - } - return (islower(cl) ? res : !res); -} - - -static int matchbracketclass (int c, const char *p, const char *ec) { - int sig = 1; - if (*(p+1) == '^') { - sig = 0; - p++; /* skip the `^' */ - } - while (++p < ec) { - if (*p == ESC) { - p++; - if (match_class(c, *p)) - return sig; - } - else if ((*(p+1) == '-') && (p+2 < ec)) { - p+=2; - if (uchar(*(p-2)) <= c && c <= uchar(*p)) - return sig; - } - else if (uchar(*p) == c) return sig; - } - return !sig; -} - - -static int luaI_singlematch (int c, const char *p, const char *ep) { - switch (*p) { - case '.': return 1; /* matches any char */ - case ESC: return match_class(c, *(p+1)); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); - } -} - - -static const char *match (MatchState *ms, const char *s, const char *p); - - -static const char *matchbalance (MatchState *ms, const char *s, - const char *p) { - if (*p == 0 || *(p+1) == 0) - luaL_error(ms->L, "unbalanced pattern"); - if (*s != *p) return NULL; - else { - int b = *p; - int e = *(p+1); - int cont = 1; - while (++s < ms->src_end) { - if (*s == e) { - if (--cont == 0) return s+1; - } - else if (*s == b) cont++; - } - } - return NULL; /* string ends out of balance */ -} - - -static const char *max_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - sint32 i = 0; /* counts maximum expand for item */ - while ((s+i)src_end && luaI_singlematch(uchar(*(s+i)), p, ep)) - i++; - /* keeps trying to match with the maximum repetitions */ - while (i>=0) { - const char *res = match(ms, (s+i), ep+1); - if (res) return res; - i--; /* else didn't match; reduce 1 repetition to try again */ - } - return NULL; -} - - -static const char *min_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - for (;;) { - const char *res = match(ms, s, ep+1); - if (res != NULL) - return res; - else if (ssrc_end && luaI_singlematch(uchar(*s), p, ep)) - s++; /* try with one more repetition */ - else return NULL; - } -} - - -static const char *start_capture (MatchState *ms, const char *s, - const char *p, int what) { - const char *res; - int level = ms->level; - if (level >= MAX_CAPTURES) luaL_error(ms->L, "too many captures"); - ms->capture[level].init = s; - ms->capture[level].len = what; - ms->level = level+1; - if ((res=match(ms, s, p)) == NULL) /* match failed? */ - ms->level--; /* undo capture */ - return res; -} - - -static const char *end_capture (MatchState *ms, const char *s, - const char *p) { - int l = capture_to_close(ms); - const char *res; - ms->capture[l].len = s - ms->capture[l].init; /* close capture */ - if ((res = match(ms, s, p)) == NULL) /* match failed? */ - ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ - return res; -} - - -static const char *match_capture (MatchState *ms, const char *s, int l) { - size_t len; - l = check_capture(ms, l); - len = ms->capture[l].len; - if ((size_t)(ms->src_end-s) >= len && - memcmp(ms->capture[l].init, s, len) == 0) - return s+len; - else return NULL; -} - - -static const char *match (MatchState *ms, const char *s, const char *p) { - init: /* using goto's to optimize tail recursion */ - switch (*p) { - case '(': { /* start capture */ - if (*(p+1) == ')') /* position capture? */ - return start_capture(ms, s, p+2, CAP_POSITION); - else - return start_capture(ms, s, p+1, CAP_UNFINISHED); - } - case ')': { /* end capture */ - return end_capture(ms, s, p+1); - } - case ESC: { - switch (*(p+1)) { - case 'b': { /* balanced string? */ - s = matchbalance(ms, s, p+2); - if (s == NULL) return NULL; - p+=4; goto init; /* else return match(ms, s, p+4); */ - } - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - luaL_error(ms->L, "missing `[' after `%%f' in pattern"); - ep = luaI_classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s-1); - if (matchbracketclass(uchar(previous), p, ep-1) || - !matchbracketclass(uchar(*s), p, ep-1)) return NULL; - p=ep; goto init; /* else return match(ms, s, ep); */ - } - default: { - if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ - s = match_capture(ms, s, *(p+1)); - if (s == NULL) return NULL; - p+=2; goto init; /* else return match(ms, s, p+2) */ - } - goto dflt; /* case default */ - } - } - } - case '\0': { /* end of pattern */ - return s; /* match succeeded */ - } - case '$': { - if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ - return (s == ms->src_end) ? s : NULL; /* check end of string */ - else goto dflt; - } - default: dflt: { /* it is a pattern item */ - const char *ep = luaI_classend(ms, p); /* points to what is next */ - int m = ssrc_end && luaI_singlematch(uchar(*s), p, ep); - switch (*ep) { - case '?': { /* optional */ - const char *res; - if (m && ((res=match(ms, s+1, ep+1)) != NULL)) - return res; - p=ep+1; goto init; /* else return match(ms, s, ep+1); */ - } - case '*': { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); - } - case '+': { /* 1 or more repetitions */ - return (m ? max_expand(ms, s+1, p, ep) : NULL); - } - case '-': { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); - } - default: { - if (!m) return NULL; - s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ - } - } - } - } -} - - - -static const char *lmemfind (const char *s1, size_t l1, - const char *s2, size_t l2) { - if (l2 == 0) return s1; /* empty strings are everywhere */ - else if (l2 > l1) return NULL; /* avoids a negative `l1' */ - else { - const char *init; /* to search for a `*s2' inside `s1' */ - l2--; /* 1st char will be checked by `memchr' */ - l1 = l1-l2; /* `s2' cannot be found after that */ - while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { - init++; /* 1st char is already checked */ - if (memcmp(init, s2+1, l2) == 0) - return init-1; - else { /* correct `l1' and `s1' to try again */ - l1 -= init-s1; - s1 = init; - } - } - return NULL; /* not found */ - } -} - - -static void push_onecapture (MatchState *ms, int i) { - int l = ms->capture[i].len; - if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); - if (l == CAP_POSITION) - lua_pushnumber(ms->L, (lua_Number)(ms->capture[i].init - ms->src_init + 1)); - else - lua_pushlstring(ms->L, ms->capture[i].init, l); -} - - -static int push_captures (MatchState *ms, const char *s, const char *e) { - int i; - luaL_checkstack(ms->L, ms->level, "too many captures"); - if (ms->level == 0 && s) { /* no explicit captures? */ - lua_pushlstring(ms->L, s, e-s); /* return whole match */ - return 1; - } - else { /* return all captures */ - for (i=0; ilevel; i++) - push_onecapture(ms, i); - return ms->level; /* number of strings pushed */ - } -} - - -static int str_find (lua_State *L) { - size_t l1, l2; - const char *s = luaL_checklstring(L, 1, &l1); - const char *p = luaL_checklstring(L, 2, &l2); - sint32 init = posrelat(luaL_optlong(L, 3, 1), l1) - 1; - if (init < 0) init = 0; - else if ((size_t)(init) > l1) init = (sint32)l1; - if (lua_toboolean(L, 4) || /* explicit request? */ - strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */ - /* do a plain search */ - const char *s2 = lmemfind(s+init, l1-init, p, l2); - if (s2) { - lua_pushnumber(L, (lua_Number)(s2-s+1)); - lua_pushnumber(L, (lua_Number)(s2-s+l2)); - return 2; - } - } - else { - MatchState ms; - int anchor = (*p == '^') ? (p++, 1) : 0; - const char *s1=s+init; - ms.L = L; - ms.src_init = s; - ms.src_end = s+l1; - do { - const char *res; - ms.level = 0; - if ((res=match(&ms, s1, p)) != NULL) { - lua_pushnumber(L, (lua_Number)(s1-s+1)); /* start */ - lua_pushnumber(L, (lua_Number)(res-s)); /* end */ - return push_captures(&ms, NULL, 0) + 2; - } - } while (s1++L; - if (lua_isstring(L, 3)) { - const char *news = lua_tostring(L, 3); - size_t l = lua_strlen(L, 3); - size_t i; - for (i=0; i= 3 && (lua_isstring(L, 3) || lua_isfunction(L, 3)), - 3, "string or function expected"); - luaL_buffinit(L, &b); - ms.L = L; - ms.src_init = src; - ms.src_end = src+srcl; - while (n < max_s) { - const char *e; - ms.level = 0; - e = match(&ms, src, p); - if (e) { - n++; - add_s(&ms, &b, src, e); - } - if (e && e>src) /* non empty match? */ - src = e; /* skip it */ - else if (src < ms.src_end) - luaL_putchar(&b, *src++); - else break; - if (anchor) break; - } - luaL_addlstring(&b, src, ms.src_end-src); - luaL_pushresult(&b); - lua_pushnumber(L, (lua_Number)n); /* number of substitutions */ - return 2; -} - -/* }====================================================== */ - - -/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ -#define MAX_ITEM 512 -/* maximum size of each format specification (such as '%-099.99d') */ -#define MAX_FORMAT 20 - - -static void luaI_addquoted (lua_State *L, luaL_Buffer *b, int arg) { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - luaL_putchar(b, '"'); - while (l--) { - switch (*s) { - case '"': case '\\': case '\n': { - luaL_putchar(b, '\\'); - luaL_putchar(b, *s); - break; - } - case '\0': { - luaL_addlstring(b, "\\000", 4); - break; - } - default: { - luaL_putchar(b, *s); - break; - } - } - s++; - } - luaL_putchar(b, '"'); -} - - -static const char *scanformat (lua_State *L, const char *strfrmt, - char *form, int *hasprecision) { - const char *p = strfrmt; - while (strchr("-+ #0", *p)) p++; /* skip flags */ - if (isdigit(uchar(*p))) p++; /* skip width */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - if (*p == '.') { - p++; - *hasprecision = 1; - if (isdigit(uchar(*p))) p++; /* skip precision */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - } - if (isdigit(uchar(*p))) - luaL_error(L, "invalid format (width or precision too long)"); - if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ - luaL_error(L, "invalid format (too long)"); - form[0] = '%'; - strncpy(form+1, strfrmt, p-strfrmt+1); - form[p-strfrmt+2] = 0; - return p; -} - - -static int str_format (lua_State *L) { - int arg = 1; - size_t sfl; - const char *strfrmt = luaL_checklstring(L, arg, &sfl); - const char *strfrmt_end = strfrmt+sfl; - luaL_Buffer b; - luaL_buffinit(L, &b); - while (strfrmt < strfrmt_end) { - if (*strfrmt != '%') - luaL_putchar(&b, *strfrmt++); - else if (*++strfrmt == '%') - luaL_putchar(&b, *strfrmt++); /* %% */ - else { /* format item */ - char form[MAX_FORMAT]; /* to store the format (`%...') */ - char buff[MAX_ITEM]; /* to store the formatted item */ - int hasprecision = 0; - if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') - return luaL_error(L, "obsolete option (d$) to `format'"); - arg++; - strfrmt = scanformat(L, strfrmt, form, &hasprecision); - switch (*strfrmt++) { - case 'c': case 'd': case 'i': { - sprintf(buff, form, luaL_checkint(L, arg)); - break; - } - case 'o': case 'u': case 'x': case 'X': { - sprintf(buff, form, (unsigned int)(luaL_checknumber(L, arg))); - break; - } - case 'e': case 'E': case 'f': - case 'g': case 'G': { - sprintf(buff, form, luaL_checknumber(L, arg)); - break; - } - case 'q': { - luaI_addquoted(L, &b, arg); - continue; /* skip the `addsize' at the end */ - } - case 's': { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - if (!hasprecision && l >= 100) { - /* no precision and string is too long to be formatted; - keep original string */ - lua_pushvalue(L, arg); - luaL_addvalue(&b); - continue; /* skip the `addsize' at the end */ - } - else { - sprintf(buff, form, s); - break; - } - } - default: { /* also treat cases `pnLlh' */ - return luaL_error(L, "invalid option to `format'"); - } - } - luaL_addlstring(&b, buff, strlen(buff)); - } - } - luaL_pushresult(&b); - return 1; -} - - -static const luaL_reg strlib[] = { - {"len", str_len}, - {"sub", str_sub}, - {"lower", str_lower}, - {"upper", str_upper}, - {"char", str_char}, - {"rep", str_rep}, - {"byte", str_byte}, - {"format", str_format}, - {"dump", str_dump}, - {"find", str_find}, - {"gfind", gfind}, - {"gsub", str_gsub}, - {NULL, NULL} -}; - - -/* -** Open string library -*/ -LUALIB_API int luaopen_string (lua_State *L) { - luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); - return 1; -} - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include +#include +#include +#include +#include + +#define lstrlib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#ifndef uchar +#define uchar(c) ((unsigned char)(c)) +#endif + + +typedef long sint32; /* a signed version for size_t */ + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushnumber(L, (lua_Number)l); + return 1; +} + + +static sint32 posrelat (sint32 pos, size_t len) { + /* relative string position: negative means back from end */ + return (pos>=0) ? pos : (sint32)len+pos+1; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + sint32 start = posrelat(luaL_checklong(L, 2), l); + sint32 end = posrelat(luaL_optlong(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (sint32)l) end = (sint32)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + sint32 pos = posrelat(luaL_optlong(L, 2, 1), l); + if (pos <= 0 || (size_t)(pos) > l) /* index out of range? */ + return 0; /* no answer */ + lua_pushnumber(L, uchar(s[pos-1])); + return 1; +} + + +static int str_char (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + luaL_Buffer b; + luaL_buffinit(L, &b); + for (i=1; i<=n; i++) { + int c = luaL_checkint(L, i); + luaL_argcheck(L, uchar(c) == c, i, "invalid value"); + luaL_putchar(&b, uchar(c)); + } + luaL_pushresult(&b); + return 1; +} + + +static int writer (lua_State *L, const void* b, size_t size, void* B) { + (void)L; + luaL_addlstring((luaL_Buffer*) B, (const char *)b, size); + return 1; +} + + +static int str_dump (lua_State *L) { + luaL_Buffer b; + luaL_checktype(L, 1, LUA_TFUNCTION); + luaL_buffinit(L,&b); + if (!lua_dump(L, writer, &b)) + luaL_error(L, "unable to dump given function"); + luaL_pushresult(&b); + return 1; +} + + + +/* +** {====================================================== +** PATTERN MATCHING +** ======================================================= +*/ + +#ifndef MAX_CAPTURES +#define MAX_CAPTURES 32 /* arbitrary limit */ +#endif + + +#define CAP_UNFINISHED (-1) +#define CAP_POSITION (-2) + +typedef struct MatchState { + const char *src_init; /* init of source string */ + const char *src_end; /* end (`\0') of source string */ + lua_State *L; + int level; /* total number of captures (finished or unfinished) */ + struct { + const char *init; + sint32 len; + } capture[MAX_CAPTURES]; +} MatchState; + + +#define ESC '%' +#define SPECIALS "^$*+?.([%-" + + +static int check_capture (MatchState *ms, int l) { + l -= '1'; + if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *luaI_classend (MatchState *ms, const char *p) { + switch (*p++) { + case ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with `%')"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing `]')"); + if (*(p++) == ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == ESC) { + p++; + if (match_class(c, *p)) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int luaI_singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case ESC: return match_class(c, *(p+1)); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + sint32 i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && luaI_singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && luaI_singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= MAX_CAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing `[' after `%%f' in pattern"); + ep = luaI_classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, *(p+1)); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = luaI_classend(ms, p); /* points to what is next */ + int m = ssrc_end && luaI_singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i) { + int l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushnumber(ms->L, (lua_Number)(ms->capture[i].init - ms->src_init + 1)); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + luaL_checkstack(ms->L, ms->level, "too many captures"); + if (ms->level == 0 && s) { /* no explicit captures? */ + lua_pushlstring(ms->L, s, e-s); /* return whole match */ + return 1; + } + else { /* return all captures */ + for (i=0; ilevel; i++) + push_onecapture(ms, i); + return ms->level; /* number of strings pushed */ + } +} + + +static int str_find (lua_State *L) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + sint32 init = posrelat(luaL_optlong(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (sint32)l1; + if (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushnumber(L, (lua_Number)(s2-s+1)); + lua_pushnumber(L, (lua_Number)(s2-s+l2)); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + lua_pushnumber(L, (lua_Number)(s1-s+1)); /* start */ + lua_pushnumber(L, (lua_Number)(res-s)); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + } while (s1++L; + if (lua_isstring(L, 3)) { + const char *news = lua_tostring(L, 3); + size_t l = lua_strlen(L, 3); + size_t i; + for (i=0; i= 3 && (lua_isstring(L, 3) || lua_isfunction(L, 3)), + 3, "string or function expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_s(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_putchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushnumber(L, (lua_Number)n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* maximum size of each format specification (such as '%-099.99d') */ +#define MAX_FORMAT 20 + + +static void luaI_addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_putchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_putchar(b, '\\'); + luaL_putchar(b, *s); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_putchar(b, *s); + break; + } + } + s++; + } + luaL_putchar(b, '"'); +} + + +static const char *scanformat (lua_State *L, const char *strfrmt, + char *form, int *hasprecision) { + const char *p = strfrmt; + while (strchr("-+ #0", *p)) p++; /* skip flags */ + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + *hasprecision = 1; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ + luaL_error(L, "invalid format (too long)"); + form[0] = '%'; + strncpy(form+1, strfrmt, p-strfrmt+1); + form[p-strfrmt+2] = 0; + return p; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != '%') + luaL_putchar(&b, *strfrmt++); + else if (*++strfrmt == '%') + luaL_putchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + int hasprecision = 0; + if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') + return luaL_error(L, "obsolete option (d$) to `format'"); + arg++; + strfrmt = scanformat(L, strfrmt, form, &hasprecision); + switch (*strfrmt++) { + case 'c': case 'd': case 'i': { + sprintf(buff, form, luaL_checkint(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + sprintf(buff, form, (unsigned int)(luaL_checknumber(L, arg))); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, luaL_checknumber(L, arg)); + break; + } + case 'q': { + luaI_addquoted(L, &b, arg); + continue; /* skip the `addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!hasprecision && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option to `format'"); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_reg strlib[] = { + {"len", str_len}, + {"sub", str_sub}, + {"lower", str_lower}, + {"upper", str_upper}, + {"char", str_char}, + {"rep", str_rep}, + {"byte", str_byte}, + {"format", str_format}, + {"dump", str_dump}, + {"find", str_find}, + {"gfind", gfind}, + {"gsub", str_gsub}, + {NULL, NULL} +}; + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); + return 1; +} + diff --git a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ltablib.c b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ltablib.c index 50fd28238..2c18bc7f7 100644 --- a/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ltablib.c +++ b/ryzom/client/src/lua_ide_dll_nevrax/source/standard/ltablib.c @@ -1,260 +1,260 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include - -#define ltablib_c - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) - - -static int luaB_foreachi (lua_State *L) { - int i; - int n = aux_getn(L, 1); - luaL_checktype(L, 2, LUA_TFUNCTION); - for (i=1; i<=n; i++) { - lua_pushvalue(L, 2); /* function */ - lua_pushnumber(L, (lua_Number)i); /* 1st argument */ - lua_rawgeti(L, 1, i); /* 2nd argument */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 1); /* remove nil result */ - } - return 0; -} - - -static int luaB_foreach (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TFUNCTION); - lua_pushnil(L); /* first key */ - for (;;) { - if (lua_next(L, 1) == 0) - return 0; - lua_pushvalue(L, 2); /* function */ - lua_pushvalue(L, -3); /* key */ - lua_pushvalue(L, -3); /* value */ - lua_call(L, 2, 1); - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 2); /* remove value and result */ - } -} - - -static int luaB_getn (lua_State *L) { - lua_pushnumber(L, (lua_Number)aux_getn(L, 1)); - return 1; -} - - -static int luaB_setn (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_setn(L, 1, luaL_checkint(L, 2)); - return 0; -} - - -static int luaB_tinsert (lua_State *L) { - int v = lua_gettop(L); /* number of arguments */ - int n = aux_getn(L, 1) + 1; - int pos; /* where to insert new element */ - if (v == 2) /* called with only 2 arguments */ - pos = n; /* insert new element at the end */ - else { - pos = luaL_checkint(L, 2); /* 2nd argument is the position */ - if (pos > n) n = pos; /* `grow' array if necessary */ - v = 3; /* function may be called with more than 3 args */ - } - luaL_setn(L, 1, n); /* new size */ - while (--n >= pos) { /* move up elements */ - lua_rawgeti(L, 1, n); - lua_rawseti(L, 1, n+1); /* t[n+1] = t[n] */ - } - lua_pushvalue(L, v); - lua_rawseti(L, 1, pos); /* t[pos] = v */ - return 0; -} - - -static int luaB_tremove (lua_State *L) { - int n = aux_getn(L, 1); - int pos = luaL_optint(L, 2, n); - if (n <= 0) return 0; /* table is `empty' */ - luaL_setn(L, 1, n-1); /* t.n = n-1 */ - lua_rawgeti(L, 1, pos); /* result = t[pos] */ - for ( ;pos= P */ - while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>u) luaL_error(L, "invalid order function for sorting"); - lua_pop(L, 1); /* remove a[i] */ - } - /* repeat --j until a[j] <= P */ - while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include + +#define ltablib_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int luaB_foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i<=n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushnumber(L, (lua_Number)i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int luaB_foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + for (;;) { + if (lua_next(L, 1) == 0) + return 0; + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } +} + + +static int luaB_getn (lua_State *L) { + lua_pushnumber(L, (lua_Number)aux_getn(L, 1)); + return 1; +} + + +static int luaB_setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_setn(L, 1, luaL_checkint(L, 2)); + return 0; +} + + +static int luaB_tinsert (lua_State *L) { + int v = lua_gettop(L); /* number of arguments */ + int n = aux_getn(L, 1) + 1; + int pos; /* where to insert new element */ + if (v == 2) /* called with only 2 arguments */ + pos = n; /* insert new element at the end */ + else { + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > n) n = pos; /* `grow' array if necessary */ + v = 3; /* function may be called with more than 3 args */ + } + luaL_setn(L, 1, n); /* new size */ + while (--n >= pos) { /* move up elements */ + lua_rawgeti(L, 1, n); + lua_rawseti(L, 1, n+1); /* t[n+1] = t[n] */ + } + lua_pushvalue(L, v); + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int luaB_tremove (lua_State *L) { + int n = aux_getn(L, 1); + int pos = luaL_optint(L, 2, n); + if (n <= 0) return 0; /* table is `empty' */ + luaL_setn(L, 1, n-1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j */ -body { background: #FFFFFF; color: #000000; margin-left: 20px; margin-right: 20px; } -body { background: #FFFFFF; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 70%; margin: 0; } -caption, a.elref, a.elref, caption { font-weight: bold; } -div.ah { background-color: #000000; color: #FFFFFF; font-weight: bold; margin-bottom: 3px; margin-top: 3px; } -div.ah{ background: #000000; color: #FFFFFF; font-weight: bold; margin-bottom: 3px; margin-top: 3px; } -div.footer{ background: #B0C2D7; border: 1px solid #436976; color: #000000; font-style: normal; margin-top: 5em; padding-bottom: 3px; text-align: center; } -div.fragment { background-color: #F5F5F5; border: 1px solid #CCCCCC; margin: 4px; padding-left: 4px; width: 98%; } -div.fragment{ background: #FFFFCC; border: 1px solid #CCCCCC; margin-left: 2em; margin-right: 2em; } -pre { font-size: 120%; margin:2px 1px 3px 1px; } -div.groupheader { font-weight: bold; margin-bottom: 6px; margin-left: 16px; margin-top: 12px; } -div.groupheader{ border-bottom: 1px solid #557E8C; font-weight: bold; margin-bottom: 6px; margin-left: 16px; margin-top: 12px; } -div.grouptext{ font-style: italic; margin-left: 16px; } -div.header{ background: #B0C2D7; border: 1px solid #436976; color: #000000; font-style: normal; margin-bottom: 1em; padding-bottom: 3px; padding-left: 10px; text-align: left; text-transform: lowercase; } -div.header a, div.footer a{ color: #436976; font-weight: bold; white-space: nowrap; } -div.header a {margin-right: 1em; } -div.header a:visited, div.footer a:visited { color: #436976; font-weight: bold; } -div.header a:hover, div.footer a:hover { color: #B52010; font-weight: bold; text-decoration: none; } -div.index { padding-right: 10px; text-align: right; } -div.maindox { margin: 2%; width: 96%; } -div.nav { float: left; } -div.qindex { background-color: #EEEEFF; border: 4px solid #EEEEFF; margin-bottom: 2px; text-align: center; width: 100%; } -dl.el { margin-left: -1cm; } -font.charliteral, span.charliteral { color: #008080; } -font.comment, span.comment { color: #800000; } -font.keyword, span.keyword { color: #008000; } -font.keywordflow, span.keywordflow { color: #E08000; } -font.keywordtype, span.keywordtype { color: #604020; } -font.preprocessor, span.preprocessor { color: #806020; } -font.stringliteral, span.stringliteral { color: #002080; } -h1{ font-size: 220%; text-align: center; } -h2{ border-bottom: 2px solid #557E8C; font-size: 170%; } -hr { border: 1px solid #000000; } -img.formuladsp { } -img.formulainl { vertical-align: middle; } -p.formuladsp { text-align: center; } -td { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 70%; } -td.indexkey{ background: #EEEEFF; font-weight: bold; margin: 2px 0px; padding: 2px 10px; } -td.indexvalue{ background: #EEEEFF; font-style: italic; margin: 2px 0px; padding: 2px 10px; } -td.md{ font-weight: bold; } -td.mdname, td.mdname1 { color: #FF9900; font-weight: bold; } -tr.memlist { background-color: #F0F0F0; } -ul { list-style-type: square; } -.mdescleft { background-color: #FAFAFA; border-bottom: 1px none #E0E0E0; border-left: 1px none #E0E0E0; border-right: 1px none #E0E0E0; border-top: 1px none #E0E0E0; margin: 0px; padding-left: 8px; } -.mdescright { background-color: #FAFAFA; border-bottom: 1px none #E0E0E0; border-left: 1px none #E0E0E0; border-right: 1px none #E0E0E0; border-top: 1px none #E0E0E0; font-style: italic; margin: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 8px; } -.mdrow { padding: 8px 20px; } -.mdtable { background: #EEEEEE; border: 1px solid #CCCCCC; } -.memitemleft { background-color: #FAFAFA; border-top-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; margin: 4px; padding: 1px 0px 0px 8px; } -.memitemright { background-color: #FAFAFA; border-top-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 13px; margin: 4px; padding: 1px 0px 0px 8px; } +a.code { color: #4444EE; font-weight: normal; text-decoration: none; } +a.coderef { color: #4444EE; font-weight: normal; } +a:link { color: #0066CC; text-decoration: none; } +a:visited { color: #436976; text-decoration: none; } +a.code{ color: #436976; font-weight: normal; text-decoration: none; } +a.coderef{ color: #436976; font-weight: normal; } +a.qindex{ font-weight: normal; white-space: nowrap; } +a.qindex:hover, a.qindexref:hover { background-color: #DDDDFF; text-decoration: none; } +a.qindexhl, a.qindexrefhl { background-color: #6666CC; color: #FFFFFF; font-weight: bold; text-decoration: none; } +a.qindexhl:hover, a.qindexrefhl:hover { background-color: #6666CC; text-decoration: none; } +a.qindexref{ } +a:hover { color: #B52010; color: #B52010; text-decoration: underline; text-decoration: underline; } +a.el, a.qindex, a.qindexref, a.el { font-weight: bold; text-decoration: none; } +/* this is repeated to fix a difference in browser rendering, perhaps should be set for each class of */ +body { background: #FFFFFF; color: #000000; margin-left: 20px; margin-right: 20px; } +body { background: #FFFFFF; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 70%; margin: 0; } +caption, a.elref, a.elref, caption { font-weight: bold; } +div.ah { background-color: #000000; color: #FFFFFF; font-weight: bold; margin-bottom: 3px; margin-top: 3px; } +div.ah{ background: #000000; color: #FFFFFF; font-weight: bold; margin-bottom: 3px; margin-top: 3px; } +div.footer{ background: #B0C2D7; border: 1px solid #436976; color: #000000; font-style: normal; margin-top: 5em; padding-bottom: 3px; text-align: center; } +div.fragment { background-color: #F5F5F5; border: 1px solid #CCCCCC; margin: 4px; padding-left: 4px; width: 98%; } +div.fragment{ background: #FFFFCC; border: 1px solid #CCCCCC; margin-left: 2em; margin-right: 2em; } +pre { font-size: 120%; margin:2px 1px 3px 1px; } +div.groupheader { font-weight: bold; margin-bottom: 6px; margin-left: 16px; margin-top: 12px; } +div.groupheader{ border-bottom: 1px solid #557E8C; font-weight: bold; margin-bottom: 6px; margin-left: 16px; margin-top: 12px; } +div.grouptext{ font-style: italic; margin-left: 16px; } +div.header{ background: #B0C2D7; border: 1px solid #436976; color: #000000; font-style: normal; margin-bottom: 1em; padding-bottom: 3px; padding-left: 10px; text-align: left; text-transform: lowercase; } +div.header a, div.footer a{ color: #436976; font-weight: bold; white-space: nowrap; } +div.header a {margin-right: 1em; } +div.header a:visited, div.footer a:visited { color: #436976; font-weight: bold; } +div.header a:hover, div.footer a:hover { color: #B52010; font-weight: bold; text-decoration: none; } +div.index { padding-right: 10px; text-align: right; } +div.maindox { margin: 2%; width: 96%; } +div.nav { float: left; } +div.qindex { background-color: #EEEEFF; border: 4px solid #EEEEFF; margin-bottom: 2px; text-align: center; width: 100%; } +dl.el { margin-left: -1cm; } +font.charliteral, span.charliteral { color: #008080; } +font.comment, span.comment { color: #800000; } +font.keyword, span.keyword { color: #008000; } +font.keywordflow, span.keywordflow { color: #E08000; } +font.keywordtype, span.keywordtype { color: #604020; } +font.preprocessor, span.preprocessor { color: #806020; } +font.stringliteral, span.stringliteral { color: #002080; } +h1{ font-size: 220%; text-align: center; } +h2{ border-bottom: 2px solid #557E8C; font-size: 170%; } +hr { border: 1px solid #000000; } +img.formuladsp { } +img.formulainl { vertical-align: middle; } +p.formuladsp { text-align: center; } +td { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 70%; } +td.indexkey{ background: #EEEEFF; font-weight: bold; margin: 2px 0px; padding: 2px 10px; } +td.indexvalue{ background: #EEEEFF; font-style: italic; margin: 2px 0px; padding: 2px 10px; } +td.md{ font-weight: bold; } +td.mdname, td.mdname1 { color: #FF9900; font-weight: bold; } +tr.memlist { background-color: #F0F0F0; } +ul { list-style-type: square; } +.mdescleft { background-color: #FAFAFA; border-bottom: 1px none #E0E0E0; border-left: 1px none #E0E0E0; border-right: 1px none #E0E0E0; border-top: 1px none #E0E0E0; margin: 0px; padding-left: 8px; } +.mdescright { background-color: #FAFAFA; border-bottom: 1px none #E0E0E0; border-left: 1px none #E0E0E0; border-right: 1px none #E0E0E0; border-top: 1px none #E0E0E0; font-style: italic; margin: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 8px; } +.mdrow { padding: 8px 20px; } +.mdtable { background: #EEEEEE; border: 1px solid #CCCCCC; } +.memitemleft { background-color: #FAFAFA; border-top-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; margin: 4px; padding: 1px 0px 0px 8px; } +.memitemright { background-color: #FAFAFA; border-top-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 13px; margin: 4px; padding: 1px 0px 0px 8px; } diff --git a/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_input.h b/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_input.h index 8a5283ed7..c2c32b8f2 100644 --- a/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_input.h +++ b/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_input.h @@ -17,7 +17,7 @@ //------------------------------------------------------------------------------------------------- // project: sadge lib // file: text_input.h -// version: $Id: text_input.h,v 1.2 2004/06/15 17:33:37 boucher Exp $ +// version: $Id$ // //------------------------------------------------------------------------------------------------- diff --git a/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h b/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h index ba77ab9e2..5d236e61e 100644 --- a/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h +++ b/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h @@ -20,7 +20,7 @@ //------------------------------------------------------------------------------------------------- // project: sadge lib // file: text_output.h -// version: $Id: text_output.h,v 1.1 2004/02/10 17:54:46 boucher Exp $ +// version: $Id$ // // This file contains a string class derived from the STL string // The string compare functions od the class are case insensitive diff --git a/ryzom/tools/pd_parser/cpp_output.h b/ryzom/tools/pd_parser/cpp_output.h index f8ed9c6f8..aea385b52 100644 --- a/ryzom/tools/pd_parser/cpp_output.h +++ b/ryzom/tools/pd_parser/cpp_output.h @@ -422,7 +422,7 @@ public: if (!description.empty()) *this << description << "\n"; *this << "\n"; - *this << "$Id: cpp_output.h,v 1.15 2004/12/13 17:19:01 legros Exp $\n"; + *this << "$Id$\n"; *this << "*/\n\n"; } } diff --git a/web/docs/admin/shard_restart/H38.css b/web/docs/admin/shard_restart/H38.css index f14991eb4..704622119 100644 --- a/web/docs/admin/shard_restart/H38.css +++ b/web/docs/admin/shard_restart/H38.css @@ -1,106 +1,106 @@ -BODY {background:#FFFFFF} - -.menuItem { - font-family:sans-serif; font-size:small; - width:220;padding-left:20; - background-color:menu; - color:black -} - -.highlightItem { - font-family:sans-serif; font-size:small; - width:220; padding-left:20; - background-Color:highlight; color:white; -} - -.navBar { - background-Color:buttonface; -} - -.oldNavBar { - background-Color:black; -} - -.pageView { - background-Color:white; -} - -.propViewer { - background-Color:white; - color: black; - font-family: Verdana; - font-style: italic; - font-weight: bold; - font-size: medium; - text-align: center; -} - -.propViewerTABLE { - background-Color: black; - font-weight: medium; - border-width: 1pt; - border-color: black; -} - -.propViewerTHEAD { - background-Color: rgb(230,230,230); - color: black; - font-family: Verdana; - font-style: italic; - font-weight: medium; - font-size: small; -} - -.propViewerHeaderSep { - background-Color: black; - height: 0pt; -} - -.propViewerLines { - background-Color: black; - height: 2pt; -} - -.propViewerTD { - font-family: Verdana; - color: black; - font-size: x-small; - font-style: normal; - align: center; -} - -.propViewerEvenRow { - background-Color: rgb(253,254,238); -} - -.propViewerOddRow { - background-Color: rgb(254,254,247); -} - -.clTab { - cursor:hand; - background:buttonface; - font: 0.7em Arial; - padding-left:3px; - padding-right:3px; - text-align:center; -} - -.clBorder { - background:windowframe; - font:1pt; -} - -.clScroll { - font:8pt Courier New; - color:threeddarkshadow; - cursor:default; - line-height:10pt; -} - -.clScroll2 { - font:10pt Arial; - color:threeddarkshadow; - cursor:default; - line-height:11pt; -} +BODY {background:#FFFFFF} + +.menuItem { + font-family:sans-serif; font-size:small; + width:220;padding-left:20; + background-color:menu; + color:black +} + +.highlightItem { + font-family:sans-serif; font-size:small; + width:220; padding-left:20; + background-Color:highlight; color:white; +} + +.navBar { + background-Color:buttonface; +} + +.oldNavBar { + background-Color:black; +} + +.pageView { + background-Color:white; +} + +.propViewer { + background-Color:white; + color: black; + font-family: Verdana; + font-style: italic; + font-weight: bold; + font-size: medium; + text-align: center; +} + +.propViewerTABLE { + background-Color: black; + font-weight: medium; + border-width: 1pt; + border-color: black; +} + +.propViewerTHEAD { + background-Color: rgb(230,230,230); + color: black; + font-family: Verdana; + font-style: italic; + font-weight: medium; + font-size: small; +} + +.propViewerHeaderSep { + background-Color: black; + height: 0pt; +} + +.propViewerLines { + background-Color: black; + height: 2pt; +} + +.propViewerTD { + font-family: Verdana; + color: black; + font-size: x-small; + font-style: normal; + align: center; +} + +.propViewerEvenRow { + background-Color: rgb(253,254,238); +} + +.propViewerOddRow { + background-Color: rgb(254,254,247); +} + +.clTab { + cursor:hand; + background:buttonface; + font: 0.7em Arial; + padding-left:3px; + padding-right:3px; + text-align:center; +} + +.clBorder { + background:windowframe; + font:1pt; +} + +.clScroll { + font:8pt Courier New; + color:threeddarkshadow; + cursor:default; + line-height:10pt; +} + +.clScroll2 { + font:10pt Arial; + color:threeddarkshadow; + cursor:default; + line-height:11pt; +} diff --git a/web/docs/admin/shard_restart/Hu37.js b/web/docs/admin/shard_restart/Hu37.js index ad988e049..ad21c0336 100644 --- a/web/docs/admin/shard_restart/Hu37.js +++ b/web/docs/admin/shard_restart/Hu37.js @@ -1,761 +1,761 @@ - -var g_theApp = parent.g_theApp; - -var layerRef=""; -var layerStyleRef = ""; -var styleSwitch = ""; -var FILEProtocol = "file://"; -var HTTPProtocol = "http://"; - -if (navigator.appName == "Netscape") - { - layerStyleRef="layer."; - layerRef="document.layers"; - styleSwitch=""; - } -else - { - layerStyleRef="layer.style."; - layerRef="document.all"; - styleSwitch=".style"; - } - -function CImage(id) - { - this.id = id; - - if ( g_theApp.isIE ) - this.image = eval('document.images.' + this.id); - else - this.image = eval('document.images["' + this.id + '"]'); - - this.put_Source = SetSource; - this.get_Source = GetSource; - this.put_Title = put_Title; - this.get_Title = get_Title; - } - -function SetSource(newsrc) - { - if ( this.image ) - this.image.src = newsrc; - } - -function GetSource() - { - if ( this.image ) - return this.image.src; - } - -function put_Title(txt) - { - if ( this.image && g_theApp.isIE ) - this.image.title = txt; - } - -function get_Title(txt) - { - if ( this.image && g_theApp.isIE ) - return this.image.title; - } - -function CDiv(id, doc) - { - this.id = id; - this.layer = FindLayer(id, doc); - - this.Show = Show; - this.Hide = Hide; - this.IsHidden = IsHidden; - this.put_innerHTML = put_innerHTML; - } - -function Show() - { - if ( this.layer ) - eval('this.' + layerStyleRef + 'visibility' + '= "visible"'); - } - -function Hide() - { - if ( this.layer ) - eval('this.' + layerStyleRef + 'visibility' + '= "hidden"'); - } - -function IsHidden() - { - if ( this.layer && - (-1 != eval('this.' + layerStyleRef + 'visibility').indexOf("hid")) ) - return true; - - return false; - } - -function put_innerHTML(txt) - { - if ( this.layer ) - { - if ( g_theApp.isIE ) - this.layer.innerHTML = txt; - else - { - this.layer.document.writeln(txt); - this.layer.document.close(); - } - } - } - -function SetZoomControl(f) - { - if ( !parent.g_NavBarLoaded ) - return; - - var formZoom = FindForm("zoomForm", parent.frmZoomBox.document); - if (formZoom != null) - { - s = formZoom.zoomFactor; - - if ( -1 != f ) - f *= 100; - - for ( i = 0 ; i < s.options.length ; i++ ) - { - if ( s.options[i].value == f ) - { - s.selectedIndex = i; - break; - } - } - } - } - -function zoom_onchange(val) -{ - if ( g_theApp.ActiveViewMgr ) - { - if ( g_theApp.ActiveViewMgr.ZoomIsPresent == true) - { - g_theApp.ActiveViewMgr.put_Zoom(parseInt(val)); - } - } -} - -function CViewMgr() - { -//Set all zoom functions to null assuming the addons related -//to the data will provide their own functions. - this.onResize = null; - this.put_Zoom = null; - this.get_Zoom = null; - this.ApplyZoom = null; - - //General functions. - this.onLoad = ViewMgrOnLoad; - this.put_Location = ViewMgrDefaultFind; //MUST BE SET FOR FIND FEATURE - this.ZoomIsPresent = false; - } - -function ViewMgrOnLoad() - { - this.id = "ConvertedImage"; - this.zoomFactor = -1; - this.zoomLast = -1; - this.origWH = 1; - this.origWidth = 100; - - if ( g_theApp.isIE ) - { - p = document.all; - this.s = document.all(this.id).style; - - - if ( this.s ) - { - this.s.position = "absolute"; - this.origWidth = this.s.pixelWidth; - this.origWH = this.s.pixelWidth / this.s.pixelHeight; - } - } - else - { - this.s = null; - } - SetZoomControl(this.zoomFactor); -} - -function ViewMgrDefaultFind() -{ - return; -} - -function handleResize() - { - location.reload(); - return false; - } - -function IsFrame(frameName) - { - return window.name == frameName; - } - -function UpdNavBar() - { - if (g_theApp.PageUpdateFunc != null) - g_theApp.PageUpdateFunc (); - - if ( parent.g_NavBarLoaded ) - //parent.frmZoomBox.UpdateNavBar(); - parent.frmNavBar.UpdateNavBar(); - } - -function UpdZoom() - { - if (g_theApp.ZoomResetFunc != null) - g_theApp.ZoomResetFunc (); - } - -function UpdCPViewer() - { - if (g_theApp.CPResetFunc != null) - g_theApp.CPResetFunc (); - } - -function UpdTitleBar() - { - if ( parent.g_TitleBarLoaded ) - parent.frmTitleBar.UpdateTitleBar(); - } - -function GetCurPageNum() { return g_theApp.CurrentPageIX; } -function GetNumPages() { return g_theApp.FileList.length; } - -function GoToNextPage() { GoToPage(g_theApp.CurrentPageIX + 1); } -function GoToPrevPage() { GoToPage(g_theApp.CurrentPageIX - 1); } -function GoToFirstPage() { GoToPage(0); } -function GoToLastPage() { GoToPage(gDocTable.length - 1) }; - -function GoToPage(ix) - { - var entry; - - if ( (g_theApp != null) && - (ix != g_theApp.CurrentPageIX) && - (null != (entry = g_theApp.FileList[ix])) ) - { - var newPage; - - if (SupportsPriOutputType ()) - { - newPage = entry.PriImage; - - if ( "" == newPage ) - newPage = newPage = entry.SecImage; - } - else - newPage = entry.SecImage; - - if (frames["frmPageView"] != null) - { - frames["frmPageView"].window.location = newPage; - } - else - { - parent.frmPageView.location = newPage; - } - - PageUpdated (ix); - } - } - -function PageUpdated (ix) -{ - g_theApp.CurrentPageIX = ix; - NotifyPageSyncs(ix); -} - -function GoToPageByName(pageName) -{ - var pageIndex = PageIndexFromName (pageName); - if (pageIndex >= 0) - { - GoToPage (pageIndex); - } -} - -function GoToPageByID(pageID) -{ - var pageIndex = PageIndexFromID (pageID); - if (pageIndex >= 0) - { - GoToPage (pageIndex); - } -} - -function PageIndexFromName (pageName) -{ - if (g_theApp != null) - { - var entry; - - var count; - var fileEntry; - var bFoundEntry = false; - for (count = 0; - count < g_theApp.FileList.length && !bFoundEntry; - count++) - { - fileEntry = g_theApp.FileList[count]; - if (pageName == fileEntry.PageName) - { - return count; - } - } - } - - return -1; -} - -function PageIndexFromID (pageID) -{ - if (g_theApp != null) - { - var entry; - - var count; - var fileEntry; - var bFoundEntry = false; - for (count = 0; - count < g_theApp.FileList.length && !bFoundEntry; - count++) - { - fileEntry = g_theApp.FileList[count]; - if (pageID == fileEntry.PageID) - { - return count; - } - } - } - return -1; -} - -function ZoomAvailable() -{ - if (SupportsPriOutputType () && g_theApp.FileList[0].PriImage != "") - { - return g_theApp.PriFormatSupportsZoom; - } - else - { - return (g_theApp.SecFormatSupportsZoom && g_theApp.FileList[0].SecImage != ""); - } -} - -function NotifyPageSyncs(ix) - { - UpdNavBar(); - UpdTitleBar(); - UpdZoom(); - UpdCPViewer(); - } - -function HasPrevSld() { return (GetCurPageNum() > 0); } -function HasNextSld() { return ((GetCurPageNum() + 1) < GetNumPages()); } - -function CancelDrag() - { - window.event.cancelBubble=true; - window.event.returnValue=false - } - -function html_escape(txt) - { - var result = ""; - - for ( var i = 0 ; i < txt.length ; i++ ) - { - if ( txt.charAt(i) == '&' ) - result += "&"; - else if ( txt.charAt(i) == '<' ) - result += "<"; - else if ( txt.charAt(i) == '>' ) - result += ">"; - else - result += txt.charAt(i); - } - - return result; - } - -function FindForm(form, doc) - { - if ( g_theApp.isIE ) - return doc.forms[form]; - else if ( null != doc ) - { - if ( null != doc.forms ) - { - for ( i = 0 ; i < doc.forms.length ; i++ ) - { - if ( form == doc.forms[i].name ) - return doc.forms[i]; - } - } - - if ( null != doc.layers ) - { - for ( i = 0 ; i < doc.layers.length ; i++ ) - { - result = FindForm(form, doc.layers[i].document); - - if ( null != result ) - return result; - } - } - } - - return null; - } - -function FindLayer(layer, doc) - { - var result = null; - - if ( g_theApp.isIE ) - return doc.all(layer); - else if ( (null != doc) && (null != doc.layers) ) - { - for ( i = 0 ; i < doc.layers.length ; i++ ) - { - result = doc.layers[i]; - - if ( layer == result.name ) - return result; - - result = FindLayer(layer, result.document); - - if ( null != result ) - return result; - } - } - - return null; - } - -function Unquote (str) -{ - var nStartIndex = 0; - var nEndIndex = str.length; - - if (str.charAt (0) == '"') - { - nStartIndex = 1; - } - - if (str.charAt (nEndIndex - 1) == '"') - { - nEndIndex -= 1; - } - - return str.substring (nStartIndex, nEndIndex); -} - -function ConvertXorYCoordinate(PosValue, OldMin, OldMax, NewMin, NewMax, MapBackwards) -{ -//This is a simple conversion routine that changes from one system to another. - var OldMid = (OldMax - OldMin) / 2; - var NewMid = (NewMax - NewMin) / 2; - var ConvertResult = 1 * PosValue; - ConvertResult = ConvertResult - (OldMin + OldMid); - ConvertResult = ConvertResult / OldMid; - if(MapBackwards != 0) - { - ConvertResult = 0 - ConvertResult; - } - ConvertResult = ConvertResult * NewMid; - ConvertResult = ConvertResult + (NewMin + NewMid); - return ConvertResult; -} - -function GoToURL (defURL) -{ - if ((g_theApp == null) || !SupportsXML () || (g_theApp.objParser == null)) - { - if (defURL.indexOf ("javascript:") == 0) - { - // This is actually a function call, not a URL. - eval (defURL); - return; - } - - parent.location = defURL; - } -} - -var el; -function showMenu(pageID, shapeID) { - - if (SupportsXML ()) - { - var shapeXML = FindShapeXML (pageID, shapeID); - if (shapeXML != null) - { - CreateHLMenu (shapeXML); - - //ContextElement=window.event.srcElement; - parent.frmPageView.menu1.style.leftPos += 10; - parent.frmPageView.menu1.style.posLeft = event.clientX; - parent.frmPageView.menu1.style.posTop = event.clientY; - parent.frmPageView.menu1.style.display = ""; - - var clientWidth = event.srcElement.document.body.clientWidth; - var clientHeight = event.srcElement.document.body.clientHeight; - - var menuWidth = parseInt (parent.frmPageView.menu1.style.width); - var margin = 10; - - // Figure out where to place the menu (X). - var menuX = event.clientX; - if (event.clientX + parent.frmPageView.menu1.clientWidth > clientWidth) - { - menuX = clientWidth - parent.frmPageView.menu1.clientWidth - margin; - if (menuX < margin) - { - menuX = margin; - } - } - - // Figure out where to place the menu (Y). - var menuY = event.clientY; - if (event.clientY + parent.frmPageView.menu1.clientHeight > clientHeight) - { - menuY = clientHeight - parent.frmPageView.menu1.clientHeight - margin; - if (menuY < margin) - { - menuY = margin; - } - } - - parent.frmPageView.menu1.style.posLeft = menuX; - parent.frmPageView.menu1.style.posTop = menuY; - - parent.frmPageView.menu1.setCapture(); - - event.cancelBubble = true; - } - } -} - -function toggleMenu() { - el=event.srcElement; - if (el.className=="menuItem") { - el.className="highlightItem"; - } else if (el.className=="highlightItem") { - el.className="menuItem"; - } -} - -function clickMenu() -{ - if (parent.frmPageView.menu1.style.display != "none") - { - parent.frmPageView.menu1.releaseCapture(); - parent.frmPageView.menu1.style.display="none"; - el=event.srcElement; - if (el.doFunction != null) { - eval(el.doFunction); - } - } -} - -function CreateHLMenu (shapeNode) -{ - // Create the HTML string. - var strHLMenuHTML = ""; - - if (shapeNode != null) - { - // Look up all the Hyperlink nodes. - var hlColl = shapeNode.selectNodes ("Scratch/B/SolutionXML/HLURL:Hyperlinks/HLURL:Hyperlink"); - - // Walk the list of Hyperlink nodes to generate the menu. - var hlCount = hlColl.length; - for (var count = 0; count < hlCount; count++) - { - var strDoFunction = ""; - var strDesc = ""; - var strAddress = ""; - - var hlAddress = hlColl.item(count).selectSingleNode("HLURL:Address/textnode()"); - if (hlAddress != null && hlAddress.text.length > 0 && IsValidAddress (hlAddress.text)) - { - strDoFunction = "'parent.location.href="; - - // Get the absolute URL. - var absoluteURL = hlColl.item(count).selectSingleNode("HLURL:AbsoluteURL/textnode()"); - if (g_theApp.DocHasBaseHL && absoluteURL != null && absoluteURL.text.length > 0) - { - // Use the absolute URL for our hyperlink. - strAddress = absoluteURL.text; - } - else - { - // Just use the address field. - strAddress = hlAddress.text; - } - - strDoFunction += '"' + EscapePath (strAddress) + '"' + ";'"; - - // Now try to get the description field. If empty, use the address as the description. - hlDesc = hlColl.item(count).selectSingleNode("HLURL:Description/textnode()"); - if (hlDesc != null && hlDesc.text.length > 0) - { - strDesc = hlDesc.text; - } - else - { - strDesc = strAddress; - } - } - else // Address is not present, assume it's a link into a different page in this document. - { - hlAddress = hlColl.item(count).selectSingleNode("HLURL:SubAddress/textnode()"); - if (hlAddress != null && hlAddress.text.length > 0) - { - strAddress = hlAddress.text; - - // Strip off the shape id (if present). - var pageShapeSep = strAddress.lastIndexOf ('/'); - if (pageShapeSep > 0) - { - strAddress = strAddress.substring (0, pageShapeSep); - } - - strAddress = unescape(strAddress); - - var pageIndex = PageIndexFromName (strAddress); - - strDoFunction = "'GoToPage (" + pageIndex + ");'"; - - // Just set the description to the page name as well. - strDesc = strAddress; - } - } - - if (strDoFunction.length > 0 && strDesc.length > 0) - { - strHLMenuHTML += ""; - } - } - } - - parent.frmPageView.menu1.innerHTML = strHLMenuHTML; -} - -function IsValidAddress (strAddress) -{ - var ret = false; - - if (strAddress != null && strAddress.length > 0) - { - var strFullPath = g_theApp.VisDocPath + g_theApp.VisDocName; - - if (strAddress != strFullPath && - strAddress != g_theApp.VisDocName) - { - // Points to something other than this file, go ahead - // and consider it valid. - ret = true; - } - } - - return ret; -} - -function FindShapeXML (pageID, shapeID) -{ - var shapeObj = null; - - if (g_theApp != null && g_theApp.objParser != null) - { - // Get the Pages collection. - var pagesObj = g_theApp.objParser.selectSingleNode("VisioDocument/Pages"); - if(!pagesObj) - { - return null; - } - - // Get the correct page. - var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; - var pageObj = pagesObj.selectSingleNode(pageQuerryString); - if(!pageObj) - { - return null; - } - - // Get the correct shape. - var shapeQuerryString = './/Shape[@ID = "' + shapeID + '"]'; - shapeObj = pageObj.selectSingleNode(shapeQuerryString); - } - - return shapeObj; -} - -function UpdateProps(pageID, shapeID) -{ - // Check to see if we should ignore this event. - if (window.event != null && - window.event.ctrlKey) - { - // If the control key is down, do nothing! - return; - } - - if (SupportsXML ()) - { - var shape = FindShapeXML (pageID, shapeID); - - if (g_theApp.custPropEntryPoint != null) - g_theApp.custPropEntryPoint (shape); - } -} - -function SupportsXML () -{ - return (g_theApp != null && g_theApp.isIE && g_theApp.verIE >= 5.0); -} - -function SupportsPriOutputType () -{ - if (g_theApp.isIE) // IE - { - return ((g_theApp.verIE >= g_theApp.PriFormatMinIE) && (g_theApp.PriFormatMinIE > 0.0)); - } - else if (g_theApp.isNav) // Nav - { - return ((g_theApp.verNav >= g_theApp.PriFormatMinNav) && (g_theApp.PriFormatMinNav > 0.0)); - } - - // Unsupported browser. - return false; -} - -function EscapePath (strPath) -{ - var strResult = ""; - - for ( var i = 0 ; i < strPath.length ; i++ ) - { - if ( strPath.charAt(i) == '\\' ) - { - strResult += "\\\\"; - } - else - { - strResult += strPath.charAt(i); - } - } - - return strResult; -} + +var g_theApp = parent.g_theApp; + +var layerRef=""; +var layerStyleRef = ""; +var styleSwitch = ""; +var FILEProtocol = "file://"; +var HTTPProtocol = "http://"; + +if (navigator.appName == "Netscape") + { + layerStyleRef="layer."; + layerRef="document.layers"; + styleSwitch=""; + } +else + { + layerStyleRef="layer.style."; + layerRef="document.all"; + styleSwitch=".style"; + } + +function CImage(id) + { + this.id = id; + + if ( g_theApp.isIE ) + this.image = eval('document.images.' + this.id); + else + this.image = eval('document.images["' + this.id + '"]'); + + this.put_Source = SetSource; + this.get_Source = GetSource; + this.put_Title = put_Title; + this.get_Title = get_Title; + } + +function SetSource(newsrc) + { + if ( this.image ) + this.image.src = newsrc; + } + +function GetSource() + { + if ( this.image ) + return this.image.src; + } + +function put_Title(txt) + { + if ( this.image && g_theApp.isIE ) + this.image.title = txt; + } + +function get_Title(txt) + { + if ( this.image && g_theApp.isIE ) + return this.image.title; + } + +function CDiv(id, doc) + { + this.id = id; + this.layer = FindLayer(id, doc); + + this.Show = Show; + this.Hide = Hide; + this.IsHidden = IsHidden; + this.put_innerHTML = put_innerHTML; + } + +function Show() + { + if ( this.layer ) + eval('this.' + layerStyleRef + 'visibility' + '= "visible"'); + } + +function Hide() + { + if ( this.layer ) + eval('this.' + layerStyleRef + 'visibility' + '= "hidden"'); + } + +function IsHidden() + { + if ( this.layer && + (-1 != eval('this.' + layerStyleRef + 'visibility').indexOf("hid")) ) + return true; + + return false; + } + +function put_innerHTML(txt) + { + if ( this.layer ) + { + if ( g_theApp.isIE ) + this.layer.innerHTML = txt; + else + { + this.layer.document.writeln(txt); + this.layer.document.close(); + } + } + } + +function SetZoomControl(f) + { + if ( !parent.g_NavBarLoaded ) + return; + + var formZoom = FindForm("zoomForm", parent.frmZoomBox.document); + if (formZoom != null) + { + s = formZoom.zoomFactor; + + if ( -1 != f ) + f *= 100; + + for ( i = 0 ; i < s.options.length ; i++ ) + { + if ( s.options[i].value == f ) + { + s.selectedIndex = i; + break; + } + } + } + } + +function zoom_onchange(val) +{ + if ( g_theApp.ActiveViewMgr ) + { + if ( g_theApp.ActiveViewMgr.ZoomIsPresent == true) + { + g_theApp.ActiveViewMgr.put_Zoom(parseInt(val)); + } + } +} + +function CViewMgr() + { +//Set all zoom functions to null assuming the addons related +//to the data will provide their own functions. + this.onResize = null; + this.put_Zoom = null; + this.get_Zoom = null; + this.ApplyZoom = null; + + //General functions. + this.onLoad = ViewMgrOnLoad; + this.put_Location = ViewMgrDefaultFind; //MUST BE SET FOR FIND FEATURE + this.ZoomIsPresent = false; + } + +function ViewMgrOnLoad() + { + this.id = "ConvertedImage"; + this.zoomFactor = -1; + this.zoomLast = -1; + this.origWH = 1; + this.origWidth = 100; + + if ( g_theApp.isIE ) + { + p = document.all; + this.s = document.all(this.id).style; + + + if ( this.s ) + { + this.s.position = "absolute"; + this.origWidth = this.s.pixelWidth; + this.origWH = this.s.pixelWidth / this.s.pixelHeight; + } + } + else + { + this.s = null; + } + SetZoomControl(this.zoomFactor); +} + +function ViewMgrDefaultFind() +{ + return; +} + +function handleResize() + { + location.reload(); + return false; + } + +function IsFrame(frameName) + { + return window.name == frameName; + } + +function UpdNavBar() + { + if (g_theApp.PageUpdateFunc != null) + g_theApp.PageUpdateFunc (); + + if ( parent.g_NavBarLoaded ) + //parent.frmZoomBox.UpdateNavBar(); + parent.frmNavBar.UpdateNavBar(); + } + +function UpdZoom() + { + if (g_theApp.ZoomResetFunc != null) + g_theApp.ZoomResetFunc (); + } + +function UpdCPViewer() + { + if (g_theApp.CPResetFunc != null) + g_theApp.CPResetFunc (); + } + +function UpdTitleBar() + { + if ( parent.g_TitleBarLoaded ) + parent.frmTitleBar.UpdateTitleBar(); + } + +function GetCurPageNum() { return g_theApp.CurrentPageIX; } +function GetNumPages() { return g_theApp.FileList.length; } + +function GoToNextPage() { GoToPage(g_theApp.CurrentPageIX + 1); } +function GoToPrevPage() { GoToPage(g_theApp.CurrentPageIX - 1); } +function GoToFirstPage() { GoToPage(0); } +function GoToLastPage() { GoToPage(gDocTable.length - 1) }; + +function GoToPage(ix) + { + var entry; + + if ( (g_theApp != null) && + (ix != g_theApp.CurrentPageIX) && + (null != (entry = g_theApp.FileList[ix])) ) + { + var newPage; + + if (SupportsPriOutputType ()) + { + newPage = entry.PriImage; + + if ( "" == newPage ) + newPage = newPage = entry.SecImage; + } + else + newPage = entry.SecImage; + + if (frames["frmPageView"] != null) + { + frames["frmPageView"].window.location = newPage; + } + else + { + parent.frmPageView.location = newPage; + } + + PageUpdated (ix); + } + } + +function PageUpdated (ix) +{ + g_theApp.CurrentPageIX = ix; + NotifyPageSyncs(ix); +} + +function GoToPageByName(pageName) +{ + var pageIndex = PageIndexFromName (pageName); + if (pageIndex >= 0) + { + GoToPage (pageIndex); + } +} + +function GoToPageByID(pageID) +{ + var pageIndex = PageIndexFromID (pageID); + if (pageIndex >= 0) + { + GoToPage (pageIndex); + } +} + +function PageIndexFromName (pageName) +{ + if (g_theApp != null) + { + var entry; + + var count; + var fileEntry; + var bFoundEntry = false; + for (count = 0; + count < g_theApp.FileList.length && !bFoundEntry; + count++) + { + fileEntry = g_theApp.FileList[count]; + if (pageName == fileEntry.PageName) + { + return count; + } + } + } + + return -1; +} + +function PageIndexFromID (pageID) +{ + if (g_theApp != null) + { + var entry; + + var count; + var fileEntry; + var bFoundEntry = false; + for (count = 0; + count < g_theApp.FileList.length && !bFoundEntry; + count++) + { + fileEntry = g_theApp.FileList[count]; + if (pageID == fileEntry.PageID) + { + return count; + } + } + } + return -1; +} + +function ZoomAvailable() +{ + if (SupportsPriOutputType () && g_theApp.FileList[0].PriImage != "") + { + return g_theApp.PriFormatSupportsZoom; + } + else + { + return (g_theApp.SecFormatSupportsZoom && g_theApp.FileList[0].SecImage != ""); + } +} + +function NotifyPageSyncs(ix) + { + UpdNavBar(); + UpdTitleBar(); + UpdZoom(); + UpdCPViewer(); + } + +function HasPrevSld() { return (GetCurPageNum() > 0); } +function HasNextSld() { return ((GetCurPageNum() + 1) < GetNumPages()); } + +function CancelDrag() + { + window.event.cancelBubble=true; + window.event.returnValue=false + } + +function html_escape(txt) + { + var result = ""; + + for ( var i = 0 ; i < txt.length ; i++ ) + { + if ( txt.charAt(i) == '&' ) + result += "&"; + else if ( txt.charAt(i) == '<' ) + result += "<"; + else if ( txt.charAt(i) == '>' ) + result += ">"; + else + result += txt.charAt(i); + } + + return result; + } + +function FindForm(form, doc) + { + if ( g_theApp.isIE ) + return doc.forms[form]; + else if ( null != doc ) + { + if ( null != doc.forms ) + { + for ( i = 0 ; i < doc.forms.length ; i++ ) + { + if ( form == doc.forms[i].name ) + return doc.forms[i]; + } + } + + if ( null != doc.layers ) + { + for ( i = 0 ; i < doc.layers.length ; i++ ) + { + result = FindForm(form, doc.layers[i].document); + + if ( null != result ) + return result; + } + } + } + + return null; + } + +function FindLayer(layer, doc) + { + var result = null; + + if ( g_theApp.isIE ) + return doc.all(layer); + else if ( (null != doc) && (null != doc.layers) ) + { + for ( i = 0 ; i < doc.layers.length ; i++ ) + { + result = doc.layers[i]; + + if ( layer == result.name ) + return result; + + result = FindLayer(layer, result.document); + + if ( null != result ) + return result; + } + } + + return null; + } + +function Unquote (str) +{ + var nStartIndex = 0; + var nEndIndex = str.length; + + if (str.charAt (0) == '"') + { + nStartIndex = 1; + } + + if (str.charAt (nEndIndex - 1) == '"') + { + nEndIndex -= 1; + } + + return str.substring (nStartIndex, nEndIndex); +} + +function ConvertXorYCoordinate(PosValue, OldMin, OldMax, NewMin, NewMax, MapBackwards) +{ +//This is a simple conversion routine that changes from one system to another. + var OldMid = (OldMax - OldMin) / 2; + var NewMid = (NewMax - NewMin) / 2; + var ConvertResult = 1 * PosValue; + ConvertResult = ConvertResult - (OldMin + OldMid); + ConvertResult = ConvertResult / OldMid; + if(MapBackwards != 0) + { + ConvertResult = 0 - ConvertResult; + } + ConvertResult = ConvertResult * NewMid; + ConvertResult = ConvertResult + (NewMin + NewMid); + return ConvertResult; +} + +function GoToURL (defURL) +{ + if ((g_theApp == null) || !SupportsXML () || (g_theApp.objParser == null)) + { + if (defURL.indexOf ("javascript:") == 0) + { + // This is actually a function call, not a URL. + eval (defURL); + return; + } + + parent.location = defURL; + } +} + +var el; +function showMenu(pageID, shapeID) { + + if (SupportsXML ()) + { + var shapeXML = FindShapeXML (pageID, shapeID); + if (shapeXML != null) + { + CreateHLMenu (shapeXML); + + //ContextElement=window.event.srcElement; + parent.frmPageView.menu1.style.leftPos += 10; + parent.frmPageView.menu1.style.posLeft = event.clientX; + parent.frmPageView.menu1.style.posTop = event.clientY; + parent.frmPageView.menu1.style.display = ""; + + var clientWidth = event.srcElement.document.body.clientWidth; + var clientHeight = event.srcElement.document.body.clientHeight; + + var menuWidth = parseInt (parent.frmPageView.menu1.style.width); + var margin = 10; + + // Figure out where to place the menu (X). + var menuX = event.clientX; + if (event.clientX + parent.frmPageView.menu1.clientWidth > clientWidth) + { + menuX = clientWidth - parent.frmPageView.menu1.clientWidth - margin; + if (menuX < margin) + { + menuX = margin; + } + } + + // Figure out where to place the menu (Y). + var menuY = event.clientY; + if (event.clientY + parent.frmPageView.menu1.clientHeight > clientHeight) + { + menuY = clientHeight - parent.frmPageView.menu1.clientHeight - margin; + if (menuY < margin) + { + menuY = margin; + } + } + + parent.frmPageView.menu1.style.posLeft = menuX; + parent.frmPageView.menu1.style.posTop = menuY; + + parent.frmPageView.menu1.setCapture(); + + event.cancelBubble = true; + } + } +} + +function toggleMenu() { + el=event.srcElement; + if (el.className=="menuItem") { + el.className="highlightItem"; + } else if (el.className=="highlightItem") { + el.className="menuItem"; + } +} + +function clickMenu() +{ + if (parent.frmPageView.menu1.style.display != "none") + { + parent.frmPageView.menu1.releaseCapture(); + parent.frmPageView.menu1.style.display="none"; + el=event.srcElement; + if (el.doFunction != null) { + eval(el.doFunction); + } + } +} + +function CreateHLMenu (shapeNode) +{ + // Create the HTML string. + var strHLMenuHTML = ""; + + if (shapeNode != null) + { + // Look up all the Hyperlink nodes. + var hlColl = shapeNode.selectNodes ("Scratch/B/SolutionXML/HLURL:Hyperlinks/HLURL:Hyperlink"); + + // Walk the list of Hyperlink nodes to generate the menu. + var hlCount = hlColl.length; + for (var count = 0; count < hlCount; count++) + { + var strDoFunction = ""; + var strDesc = ""; + var strAddress = ""; + + var hlAddress = hlColl.item(count).selectSingleNode("HLURL:Address/textnode()"); + if (hlAddress != null && hlAddress.text.length > 0 && IsValidAddress (hlAddress.text)) + { + strDoFunction = "'parent.location.href="; + + // Get the absolute URL. + var absoluteURL = hlColl.item(count).selectSingleNode("HLURL:AbsoluteURL/textnode()"); + if (g_theApp.DocHasBaseHL && absoluteURL != null && absoluteURL.text.length > 0) + { + // Use the absolute URL for our hyperlink. + strAddress = absoluteURL.text; + } + else + { + // Just use the address field. + strAddress = hlAddress.text; + } + + strDoFunction += '"' + EscapePath (strAddress) + '"' + ";'"; + + // Now try to get the description field. If empty, use the address as the description. + hlDesc = hlColl.item(count).selectSingleNode("HLURL:Description/textnode()"); + if (hlDesc != null && hlDesc.text.length > 0) + { + strDesc = hlDesc.text; + } + else + { + strDesc = strAddress; + } + } + else // Address is not present, assume it's a link into a different page in this document. + { + hlAddress = hlColl.item(count).selectSingleNode("HLURL:SubAddress/textnode()"); + if (hlAddress != null && hlAddress.text.length > 0) + { + strAddress = hlAddress.text; + + // Strip off the shape id (if present). + var pageShapeSep = strAddress.lastIndexOf ('/'); + if (pageShapeSep > 0) + { + strAddress = strAddress.substring (0, pageShapeSep); + } + + strAddress = unescape(strAddress); + + var pageIndex = PageIndexFromName (strAddress); + + strDoFunction = "'GoToPage (" + pageIndex + ");'"; + + // Just set the description to the page name as well. + strDesc = strAddress; + } + } + + if (strDoFunction.length > 0 && strDesc.length > 0) + { + strHLMenuHTML += ""; + } + } + } + + parent.frmPageView.menu1.innerHTML = strHLMenuHTML; +} + +function IsValidAddress (strAddress) +{ + var ret = false; + + if (strAddress != null && strAddress.length > 0) + { + var strFullPath = g_theApp.VisDocPath + g_theApp.VisDocName; + + if (strAddress != strFullPath && + strAddress != g_theApp.VisDocName) + { + // Points to something other than this file, go ahead + // and consider it valid. + ret = true; + } + } + + return ret; +} + +function FindShapeXML (pageID, shapeID) +{ + var shapeObj = null; + + if (g_theApp != null && g_theApp.objParser != null) + { + // Get the Pages collection. + var pagesObj = g_theApp.objParser.selectSingleNode("VisioDocument/Pages"); + if(!pagesObj) + { + return null; + } + + // Get the correct page. + var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; + var pageObj = pagesObj.selectSingleNode(pageQuerryString); + if(!pageObj) + { + return null; + } + + // Get the correct shape. + var shapeQuerryString = './/Shape[@ID = "' + shapeID + '"]'; + shapeObj = pageObj.selectSingleNode(shapeQuerryString); + } + + return shapeObj; +} + +function UpdateProps(pageID, shapeID) +{ + // Check to see if we should ignore this event. + if (window.event != null && + window.event.ctrlKey) + { + // If the control key is down, do nothing! + return; + } + + if (SupportsXML ()) + { + var shape = FindShapeXML (pageID, shapeID); + + if (g_theApp.custPropEntryPoint != null) + g_theApp.custPropEntryPoint (shape); + } +} + +function SupportsXML () +{ + return (g_theApp != null && g_theApp.isIE && g_theApp.verIE >= 5.0); +} + +function SupportsPriOutputType () +{ + if (g_theApp.isIE) // IE + { + return ((g_theApp.verIE >= g_theApp.PriFormatMinIE) && (g_theApp.PriFormatMinIE > 0.0)); + } + else if (g_theApp.isNav) // Nav + { + return ((g_theApp.verNav >= g_theApp.PriFormatMinNav) && (g_theApp.PriFormatMinNav > 0.0)); + } + + // Unsupported browser. + return false; +} + +function EscapePath (strPath) +{ + var strResult = ""; + + for ( var i = 0 ; i < strPath.length ; i++ ) + { + if ( strPath.charAt(i) == '\\' ) + { + strResult += "\\\\"; + } + else + { + strResult += strPath.charAt(i); + } + } + + return strResult; +} diff --git a/web/public_php/admin/overlib/overlib.js b/web/public_php/admin/overlib/overlib.js index 7fc66d4a3..e9e1823f5 100644 --- a/web/public_php/admin/overlib/overlib.js +++ b/web/public_php/admin/overlib/overlib.js @@ -1,1491 +1,1491 @@ -//\///// -//\ overLIB 4.21 - You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2004. All rights reserved. -//\ -//\ Contributors are listed on the homepage. -//\ This file might be old, always check for the latest version at: -//\ http://www.bosrup.com/web/overlib/ -//\ -//\ Please read the license agreement (available through the link above) -//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. -//\ -//\ Do not sell this as your own work or remove this copyright notice. -//\ For full details on copying or changing this script please read the -//\ license agreement at the link above. Please give credit on sites that -//\ use overLIB and submit changes of the script so other people can use -//\ them as well. -// $Revision: 1.1 $ $Date: 2006/05/29 16:38:21 $ -//\///// -//\mini - -//////// -// PRE-INIT -// Ignore these lines, configuration is below. -//////// -var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1; var pmt=''; var pms = new Array(); var olInfo = new Info('4.21', 1); -var FREPLACE = 0; var FBEFORE = 1; var FAFTER = 2; var FALTERNATE = 3; var FCHAIN=4; -var olHideForm=0; // parameter for hiding SELECT and ActiveX elements in IE5.5+ -var olHautoFlag = 0; // flags for over-riding VAUTO and HAUTO if corresponding -var olVautoFlag = 0; // positioning commands are used on the command line -var hookPts = new Array(), postParse = new Array(), cmdLine = new Array(), runTime = new Array(); -// for plugins -registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass'); - -//////// -// DEFAULT CONFIGURATION -// Settings you want everywhere are set here. All of this can also be -// changed on your html page or through an overLIB call. -//////// -if (typeof ol_fgcolor=='undefined') var ol_fgcolor="#99BBDD"; -if (typeof ol_bgcolor=='undefined') var ol_bgcolor="#7799BB"; -if (typeof ol_textcolor=='undefined') var ol_textcolor="#000000"; -if (typeof ol_capcolor=='undefined') var ol_capcolor="#000033"; -if (typeof ol_closecolor=='undefined') var ol_closecolor="#000000"; -if (typeof ol_textfont=='undefined') var ol_textfont="Verdana,Arial,Helvetica"; -if (typeof ol_captionfont=='undefined') var ol_captionfont="Verdana,Arial,Helvetica"; -if (typeof ol_closefont=='undefined') var ol_closefont="Verdana,Arial,Helvetica"; -if (typeof ol_textsize=='undefined') var ol_textsize="1"; -if (typeof ol_captionsize=='undefined') var ol_captionsize="1"; -if (typeof ol_closesize=='undefined') var ol_closesize="1"; -if (typeof ol_width=='undefined') var ol_width="200"; -if (typeof ol_border=='undefined') var ol_border="1"; -if (typeof ol_cellpad=='undefined') var ol_cellpad=2; -if (typeof ol_offsetx=='undefined') var ol_offsetx=10; -if (typeof ol_offsety=='undefined') var ol_offsety=10; -if (typeof ol_text=='undefined') var ol_text="Default Text"; -if (typeof ol_cap=='undefined') var ol_cap=""; -if (typeof ol_sticky=='undefined') var ol_sticky=0; -if (typeof ol_background=='undefined') var ol_background=""; -if (typeof ol_close=='undefined') var ol_close="Close"; -if (typeof ol_hpos=='undefined') var ol_hpos=RIGHT; -if (typeof ol_status=='undefined') var ol_status=""; -if (typeof ol_autostatus=='undefined') var ol_autostatus=0; -if (typeof ol_height=='undefined') var ol_height=-1; -if (typeof ol_snapx=='undefined') var ol_snapx=0; -if (typeof ol_snapy=='undefined') var ol_snapy=0; -if (typeof ol_fixx=='undefined') var ol_fixx=-1; -if (typeof ol_fixy=='undefined') var ol_fixy=-1; -if (typeof ol_relx=='undefined') var ol_relx=null; -if (typeof ol_rely=='undefined') var ol_rely=null; -if (typeof ol_fgbackground=='undefined') var ol_fgbackground=""; -if (typeof ol_bgbackground=='undefined') var ol_bgbackground=""; -if (typeof ol_padxl=='undefined') var ol_padxl=1; -if (typeof ol_padxr=='undefined') var ol_padxr=1; -if (typeof ol_padyt=='undefined') var ol_padyt=1; -if (typeof ol_padyb=='undefined') var ol_padyb=1; -if (typeof ol_fullhtml=='undefined') var ol_fullhtml=0; -if (typeof ol_vpos=='undefined') var ol_vpos=BELOW; -if (typeof ol_aboveheight=='undefined') var ol_aboveheight=0; -if (typeof ol_capicon=='undefined') var ol_capicon=""; -if (typeof ol_frame=='undefined') var ol_frame=self; -if (typeof ol_timeout=='undefined') var ol_timeout=0; -if (typeof ol_function=='undefined') var ol_function=null; -if (typeof ol_delay=='undefined') var ol_delay=0; -if (typeof ol_hauto=='undefined') var ol_hauto=0; -if (typeof ol_vauto=='undefined') var ol_vauto=0; -if (typeof ol_closeclick=='undefined') var ol_closeclick=0; -if (typeof ol_wrap=='undefined') var ol_wrap=0; -if (typeof ol_followmouse=='undefined') var ol_followmouse=1; -if (typeof ol_mouseoff=='undefined') var ol_mouseoff=0; -if (typeof ol_closetitle=='undefined') var ol_closetitle='Close'; -if (typeof ol_compatmode=='undefined') var ol_compatmode=0; -if (typeof ol_css=='undefined') var ol_css=CSSOFF; -if (typeof ol_fgclass=='undefined') var ol_fgclass=""; -if (typeof ol_bgclass=='undefined') var ol_bgclass=""; -if (typeof ol_textfontclass=='undefined') var ol_textfontclass=""; -if (typeof ol_captionfontclass=='undefined') var ol_captionfontclass=""; -if (typeof ol_closefontclass=='undefined') var ol_closefontclass=""; - -//////// -// ARRAY CONFIGURATION -//////// - -// You can use these arrays to store popup text here instead of in the html. -if (typeof ol_texts=='undefined') var ol_texts = new Array("Text 0", "Text 1"); -if (typeof ol_caps=='undefined') var ol_caps = new Array("Caption 0", "Caption 1"); - -//////// -// END OF CONFIGURATION -// Don't change anything below this line, all configuration is above. -//////// - - - - - -//////// -// INIT -//////// -// Runtime variables init. Don't change for config! -var o3_text=""; -var o3_cap=""; -var o3_sticky=0; -var o3_background=""; -var o3_close="Close"; -var o3_hpos=RIGHT; -var o3_offsetx=2; -var o3_offsety=2; -var o3_fgcolor=""; -var o3_bgcolor=""; -var o3_textcolor=""; -var o3_capcolor=""; -var o3_closecolor=""; -var o3_width=100; -var o3_border=1; -var o3_cellpad=2; -var o3_status=""; -var o3_autostatus=0; -var o3_height=-1; -var o3_snapx=0; -var o3_snapy=0; -var o3_fixx=-1; -var o3_fixy=-1; -var o3_relx=null; -var o3_rely=null; -var o3_fgbackground=""; -var o3_bgbackground=""; -var o3_padxl=0; -var o3_padxr=0; -var o3_padyt=0; -var o3_padyb=0; -var o3_fullhtml=0; -var o3_vpos=BELOW; -var o3_aboveheight=0; -var o3_capicon=""; -var o3_textfont="Verdana,Arial,Helvetica"; -var o3_captionfont="Verdana,Arial,Helvetica"; -var o3_closefont="Verdana,Arial,Helvetica"; -var o3_textsize="1"; -var o3_captionsize="1"; -var o3_closesize="1"; -var o3_frame=self; -var o3_timeout=0; -var o3_timerid=0; -var o3_allowmove=0; -var o3_function=null; -var o3_delay=0; -var o3_delayid=0; -var o3_hauto=0; -var o3_vauto=0; -var o3_closeclick=0; -var o3_wrap=0; -var o3_followmouse=1; -var o3_mouseoff=0; -var o3_closetitle=''; -var o3_compatmode=0; -var o3_css=CSSOFF; -var o3_fgclass=""; -var o3_bgclass=""; -var o3_textfontclass=""; -var o3_captionfontclass=""; -var o3_closefontclass=""; - -// Display state variables -var o3_x = 0; -var o3_y = 0; -var o3_showingsticky = 0; -var o3_removecounter = 0; - -// Our layer -var over = null; -var fnRef, hoveringSwitch = false; -var olHideDelay; - -// Decide browser version -var isMac = (navigator.userAgent.indexOf("Mac") != -1); -var olOp = (navigator.userAgent.toLowerCase().indexOf('opera') > -1 && document.createTextNode); // Opera 7 -var olNs4 = (navigator.appName=='Netscape' && parseInt(navigator.appVersion) == 4); -var olNs6 = (document.getElementById) ? true : false; -var olKq = (olNs6 && /konqueror/i.test(navigator.userAgent)); -var olIe4 = (document.all) ? true : false; -var olIe5 = false; -var olIe55 = false; // Added additional variable to identify IE5.5+ -var docRoot = 'document.body'; - -// Resize fix for NS4.x to keep track of layer -if (olNs4) { - var oW = window.innerWidth; - var oH = window.innerHeight; - window.onresize = function() { if (oW != window.innerWidth || oH != window.innerHeight) location.reload(); } -} - -// Microsoft Stupidity Check(tm). -if (olIe4) { - var agent = navigator.userAgent; - if (/MSIE/.test(agent)) { - var versNum = parseFloat(agent.match(/MSIE[ ](\d\.\d+)\.*/i)[1]); - if (versNum >= 5){ - olIe5=true; - olIe55=(versNum>=5.5&&!olOp) ? true : false; - if (olNs6) olNs6=false; - } - } - if (olNs6) olIe4 = false; -} - -// Check for compatability mode. -if (document.compatMode && document.compatMode == 'CSS1Compat') { - docRoot= ((olIe4 && !olOp) ? 'document.documentElement' : docRoot); -} - -// Add window onload handlers to indicate when all modules have been loaded -// For Netscape 6+ and Mozilla, uses addEventListener method on the window object -// For IE it uses the attachEvent method of the window object and for Netscape 4.x -// it sets the window.onload handler to the OLonload_handler function for Bubbling -if(window.addEventListener) window.addEventListener("load",OLonLoad_handler,false); -else if (window.attachEvent) window.attachEvent("onload",OLonLoad_handler); - -var capExtent; - -//////// -// PUBLIC FUNCTIONS -//////// - -// overlib(arg0,...,argN) -// Loads parameters into global runtime variables. -function overlib() { - if (!olLoaded || isExclusive(overlib.arguments)) return true; - if (olCheckMouseCapture) olMouseCapture(); - if (over) { - over = (typeof over.id != 'string') ? o3_frame.document.all['overDiv'] : over; - cClick(); - } - - // Load defaults to runtime. - olHideDelay=0; - o3_text=ol_text; - o3_cap=ol_cap; - o3_sticky=ol_sticky; - o3_background=ol_background; - o3_close=ol_close; - o3_hpos=ol_hpos; - o3_offsetx=ol_offsetx; - o3_offsety=ol_offsety; - o3_fgcolor=ol_fgcolor; - o3_bgcolor=ol_bgcolor; - o3_textcolor=ol_textcolor; - o3_capcolor=ol_capcolor; - o3_closecolor=ol_closecolor; - o3_width=ol_width; - o3_border=ol_border; - o3_cellpad=ol_cellpad; - o3_status=ol_status; - o3_autostatus=ol_autostatus; - o3_height=ol_height; - o3_snapx=ol_snapx; - o3_snapy=ol_snapy; - o3_fixx=ol_fixx; - o3_fixy=ol_fixy; - o3_relx=ol_relx; - o3_rely=ol_rely; - o3_fgbackground=ol_fgbackground; - o3_bgbackground=ol_bgbackground; - o3_padxl=ol_padxl; - o3_padxr=ol_padxr; - o3_padyt=ol_padyt; - o3_padyb=ol_padyb; - o3_fullhtml=ol_fullhtml; - o3_vpos=ol_vpos; - o3_aboveheight=ol_aboveheight; - o3_capicon=ol_capicon; - o3_textfont=ol_textfont; - o3_captionfont=ol_captionfont; - o3_closefont=ol_closefont; - o3_textsize=ol_textsize; - o3_captionsize=ol_captionsize; - o3_closesize=ol_closesize; - o3_timeout=ol_timeout; - o3_function=ol_function; - o3_delay=ol_delay; - o3_hauto=ol_hauto; - o3_vauto=ol_vauto; - o3_closeclick=ol_closeclick; - o3_wrap=ol_wrap; - o3_followmouse=ol_followmouse; - o3_mouseoff=ol_mouseoff; - o3_closetitle=ol_closetitle; - o3_css=ol_css; - o3_compatmode=ol_compatmode; - o3_fgclass=ol_fgclass; - o3_bgclass=ol_bgclass; - o3_textfontclass=ol_textfontclass; - o3_captionfontclass=ol_captionfontclass; - o3_closefontclass=ol_closefontclass; - - setRunTimeVariables(); - - fnRef = ''; - - // Special for frame support, over must be reset... - o3_frame = ol_frame; - - if(!(over=createDivContainer())) return false; - - parseTokens('o3_', overlib.arguments); - if (!postParseChecks()) return false; - - if (o3_delay == 0) { - return runHook("olMain", FREPLACE); - } else { - o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay); - return false; - } -} - -// Clears popups if appropriate -function nd(time) { - if (olLoaded && !isExclusive()) { - hideDelay(time); // delay popup close if time specified - - if (o3_removecounter >= 1) { o3_showingsticky = 0 }; - - if (o3_showingsticky == 0) { - o3_allowmove = 0; - if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over); - } else { - o3_removecounter++; - } - } - - return true; -} - -// The Close onMouseOver function for stickies -function cClick() { - if (olLoaded) { - runHook("hideObject", FREPLACE, over); - o3_showingsticky = 0; - } - return false; -} - -// Method for setting page specific defaults. -function overlib_pagedefaults() { - parseTokens('ol_', overlib_pagedefaults.arguments); -} - - -//////// -// OVERLIB MAIN FUNCTION -//////// - -// This function decides what it is we want to display and how we want it done. -function olMain() { - var layerhtml, styleType; - runHook("olMain", FBEFORE); - - if (o3_background!="" || o3_fullhtml) { - // Use background instead of box. - layerhtml = runHook('ol_content_background', FALTERNATE, o3_css, o3_text, o3_background, o3_fullhtml); - } else { - // They want a popup box. - styleType = (pms[o3_css-1-pmStart] == "cssoff" || pms[o3_css-1-pmStart] == "cssclass"); - - // Prepare popup background - if (o3_fgbackground != "") o3_fgbackground = "background=\""+o3_fgbackground+"\""; - if (o3_bgbackground != "") o3_bgbackground = (styleType ? "background=\""+o3_bgbackground+"\"" : o3_bgbackground); - - // Prepare popup colors - if (o3_fgcolor != "") o3_fgcolor = (styleType ? "bgcolor=\""+o3_fgcolor+"\"" : o3_fgcolor); - if (o3_bgcolor != "") o3_bgcolor = (styleType ? "bgcolor=\""+o3_bgcolor+"\"" : o3_bgcolor); - - // Prepare popup height - if (o3_height > 0) o3_height = (styleType ? "height=\""+o3_height+"\"" : o3_height); - else o3_height = ""; - - // Decide which kinda box. - if (o3_cap=="") { - // Plain - layerhtml = runHook('ol_content_simple', FALTERNATE, o3_css, o3_text); - } else { - // With caption - if (o3_sticky) { - // Show close text - layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close); - } else { - // No close text - layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, ""); - } - } - } - - // We want it to stick! - if (o3_sticky) { - if (o3_timerid > 0) { - clearTimeout(o3_timerid); - o3_timerid = 0; - } - o3_showingsticky = 1; - o3_removecounter = 0; - } - - // Created a separate routine to generate the popup to make it easier - // to implement a plugin capability - if (!runHook("createPopup", FREPLACE, layerhtml)) return false; - - // Prepare status bar - if (o3_autostatus > 0) { - o3_status = o3_text; - if (o3_autostatus > 1) o3_status = o3_cap; - } - - // When placing the layer the first time, even stickies may be moved. - o3_allowmove = 0; - - // Initiate a timer for timeout - if (o3_timeout > 0) { - if (o3_timerid > 0) clearTimeout(o3_timerid); - o3_timerid = setTimeout("cClick()", o3_timeout); - } - - // Show layer - runHook("disp", FREPLACE, o3_status); - runHook("olMain", FAFTER); - - return (olOp && event && event.type == 'mouseover' && !o3_status) ? '' : (o3_status != ''); -} - -//////// -// LAYER GENERATION FUNCTIONS -//////// -// These functions just handle popup content with tags that should adhere to the W3C standards specification. - -// Makes simple table without caption -function ol_content_simple(text) { - var cpIsMultiple = /,/.test(o3_cellpad); - var txt = '
' : ((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'
'; - - set_background(""); - return txt; -} - -// Makes table with caption and optional close link -function ol_content_caption(text,title,close) { - var nameId, txt, cpIsMultiple = /,/.test(o3_cellpad); - var closing, closeevent; - - closing = ""; - closeevent = "onmouseover"; - if (o3_closeclick == 1) closeevent = (o3_closetitle ? "title='" + o3_closetitle +"'" : "") + " onclick"; - if (o3_capicon != "") { - nameId = ' hspace = \"5\"'+' align = \"middle\" alt = \"\"'; - if (typeof o3_dragimg != 'undefined' && o3_dragimg) nameId =' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"'; - o3_capicon = ''; - } - - if (close != "") - closing = '
'+(o3_closefontclass ? '' : wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass ? '' : wrapStr(1,o3_closesize,'close'))+''; - txt = '
' : '>')+(o3_captionfontclass ? '' : ''+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass ? '' : wrapStr(1,o3_captionsize)+'')+''+closing+'
' :((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize)) + '
'; - - set_background(""); - return txt; -} - -// Sets the background picture,padding and lots more. :) -function ol_content_background(text,picture,hasfullhtml) { - if (hasfullhtml) { - txt=text; - } else { - txt='
'+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'
'; - } - - set_background(picture); - return txt; -} - -// Loads a picture into the div. -function set_background(pic) { - if (pic == "") { - if (olNs4) { - over.background.src = null; - } else if (over.style) { - over.style.backgroundImage = "none"; - } - } else { - if (olNs4) { - over.background.src = pic; - } else if (over.style) { - over.style.width=o3_width + 'px'; - over.style.backgroundImage = "url("+pic+")"; - } - } -} - -//////// -// HANDLING FUNCTIONS -//////// -var olShowId=-1; - -// Displays the popup -function disp(statustext) { - runHook("disp", FBEFORE); - - if (o3_allowmove == 0) { - runHook("placeLayer", FREPLACE); - (olNs6&&olShowId<0) ? olShowId=setTimeout("runHook('showObject', FREPLACE, over)", 1) : runHook("showObject", FREPLACE, over); - o3_allowmove = (o3_sticky || o3_followmouse==0) ? 0 : 1; - } - - runHook("disp", FAFTER); - - if (statustext != "") self.status = statustext; -} - -// Creates the actual popup structure -function createPopup(lyrContent){ - runHook("createPopup", FBEFORE); - - if (o3_wrap) { - var wd,ww,theObj = (olNs4 ? over : over.style); - theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0); - layerWrite(lyrContent); - wd = (olNs4 ? over.clip.width : over.offsetWidth); - if (wd > (ww=windowWidth())) { - lyrContent=lyrContent.replace(/\ /g, ' '); - o3_width=ww; - o3_wrap=0; - } - } - - layerWrite(lyrContent); - - // Have to set o3_width for placeLayer() routine if o3_wrap is turned on - if (o3_wrap) o3_width=(olNs4 ? over.clip.width : over.offsetWidth); - - runHook("createPopup", FAFTER, lyrContent); - - return true; -} - -// Decides where we want the popup. -function placeLayer() { - var placeX, placeY, widthFix = 0; - - // HORIZONTAL PLACEMENT, re-arranged to work in Safari - if (o3_frame.innerWidth) widthFix=18; - iwidth = windowWidth(); - - // Horizontal scroll offset - winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset; - - placeX = runHook('horizontalPlacement',FCHAIN,iwidth,winoffset,widthFix); - - // VERTICAL PLACEMENT, re-arranged to work in Safari - if (o3_frame.innerHeight) { - iheight=o3_frame.innerHeight; - } else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientHeight=='number'")&&eval('o3_frame.'+docRoot+'.clientHeight')) { - iheight=eval('o3_frame.'+docRoot+'.clientHeight'); - } - - // Vertical scroll offset - scrolloffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollTop') : o3_frame.pageYOffset; - placeY = runHook('verticalPlacement',FCHAIN,iheight,scrolloffset); - - // Actually move the object. - repositionTo(over, placeX, placeY); -} - -// Moves the layer -function olMouseMove(e) { - var e = (e) ? e : event; - - if (e.pageX) { - o3_x = e.pageX; - o3_y = e.pageY; - } else if (e.clientX) { - o3_x = eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft'); - o3_y = eval('e.clientY+o3_frame.'+docRoot+'.scrollTop'); - } - - if (o3_allowmove == 1) runHook("placeLayer", FREPLACE); - - // MouseOut handler - if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) { - (olHideDelay ? hideDelay(olHideDelay) : cClick()); - hoveringSwitch = !hoveringSwitch; - } -} - -// Fake function for 3.0 users. -function no_overlib() { return ver3fix; } - -// Capture the mouse and chain other scripts. -function olMouseCapture() { - capExtent = document; - var fN, str = '', l, k, f, wMv, sS, mseHandler = olMouseMove; - var re = /function[ ]*(\w*)\(/; - - wMv = (!olIe4 && window.onmousemove); - if (document.onmousemove || wMv) { - if (wMv) capExtent = window; - f = capExtent.onmousemove.toString(); - fN = f.match(re); - if (fN == null) { - str = f+'(e); '; - } else if (fN[1] == 'anonymous' || fN[1] == 'olMouseMove' || (wMv && fN[1] == 'onmousemove')) { - if (!olOp && wMv) { - l = f.indexOf('{')+1; - k = f.lastIndexOf('}'); - sS = f.substring(l,k); - if ((l = sS.indexOf('(')) != -1) { - sS = sS.substring(0,l).replace(/^\s+/,'').replace(/\s+$/,''); - if (eval("typeof " + sS + " == 'undefined'")) window.onmousemove = null; - else str = sS + '(e);'; - } - } - if (!str) { - olCheckMouseCapture = false; - return; - } - } else { - if (fN[1]) str = fN[1]+'(e); '; - else { - l = f.indexOf('{')+1; - k = f.lastIndexOf('}'); - str = f.substring(l,k) + '\n'; - } - } - str += 'olMouseMove(e); '; - mseHandler = new Function('e', str); - } - - capExtent.onmousemove = mseHandler; - if (olNs4) capExtent.captureEvents(Event.MOUSEMOVE); -} - -//////// -// PARSING FUNCTIONS -//////// - -// Does the actual command parsing. -function parseTokens(pf, ar) { - // What the next argument is expected to be. - var v, i, mode=-1, par = (pf != 'ol_'); - var fnMark = (par && !ar.length ? 1 : 0); - - for (i = 0; i < ar.length; i++) { - if (mode < 0) { - // Arg is maintext,unless its a number between pmStart and pmUpper - // then its a command. - if (typeof ar[i] == 'number' && ar[i] > pmStart && ar[i] < pmUpper) { - fnMark = (par ? 1 : 0); - i--; // backup one so that the next block can parse it - } else { - switch(pf) { - case 'ol_': - ol_text = ar[i].toString(); - break; - default: - o3_text=ar[i].toString(); - } - } - mode = 0; - } else { - // Note: NS4 doesn't like switch cases with vars. - if (ar[i] >= pmCount || ar[i]==DONOTHING) { continue; } - if (ar[i]==INARRAY) { fnMark = 0; eval(pf+'text=ol_texts['+ar[++i]+'].toString()'); continue; } - if (ar[i]==CAPARRAY) { eval(pf+'cap=ol_caps['+ar[++i]+'].toString()'); continue; } - if (ar[i]==STICKY) { if (pf!='ol_') eval(pf+'sticky=1'); continue; } - if (ar[i]==BACKGROUND) { eval(pf+'background="'+ar[++i]+'"'); continue; } - if (ar[i]==NOCLOSE) { if (pf!='ol_') opt_NOCLOSE(); continue; } - if (ar[i]==CAPTION) { eval(pf+"cap='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==CENTER || ar[i]==LEFT || ar[i]==RIGHT) { eval(pf+'hpos='+ar[i]); if(pf!='ol_') olHautoFlag=1; continue; } - if (ar[i]==OFFSETX) { eval(pf+'offsetx='+ar[++i]); continue; } - if (ar[i]==OFFSETY) { eval(pf+'offsety='+ar[++i]); continue; } - if (ar[i]==FGCOLOR) { eval(pf+'fgcolor="'+ar[++i]+'"'); continue; } - if (ar[i]==BGCOLOR) { eval(pf+'bgcolor="'+ar[++i]+'"'); continue; } - if (ar[i]==TEXTCOLOR) { eval(pf+'textcolor="'+ar[++i]+'"'); continue; } - if (ar[i]==CAPCOLOR) { eval(pf+'capcolor="'+ar[++i]+'"'); continue; } - if (ar[i]==CLOSECOLOR) { eval(pf+'closecolor="'+ar[++i]+'"'); continue; } - if (ar[i]==WIDTH) { eval(pf+'width='+ar[++i]); continue; } - if (ar[i]==BORDER) { eval(pf+'border='+ar[++i]); continue; } - if (ar[i]==CELLPAD) { i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad')); continue; } - if (ar[i]==STATUS) { eval(pf+"status='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==AUTOSTATUS) { eval(pf +'autostatus=('+pf+'autostatus == 1) ? 0 : 1'); continue; } - if (ar[i]==AUTOSTATUSCAP) { eval(pf +'autostatus=('+pf+'autostatus == 2) ? 0 : 2'); continue; } - if (ar[i]==HEIGHT) { eval(pf+'height='+pf+'aboveheight='+ar[++i]); continue; } // Same param again. - if (ar[i]==CLOSETEXT) { eval(pf+"close='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==SNAPX) { eval(pf+'snapx='+ar[++i]); continue; } - if (ar[i]==SNAPY) { eval(pf+'snapy='+ar[++i]); continue; } - if (ar[i]==FIXX) { eval(pf+'fixx='+ar[++i]); continue; } - if (ar[i]==FIXY) { eval(pf+'fixy='+ar[++i]); continue; } - if (ar[i]==RELX) { eval(pf+'relx='+ar[++i]); continue; } - if (ar[i]==RELY) { eval(pf+'rely='+ar[++i]); continue; } - if (ar[i]==FGBACKGROUND) { eval(pf+'fgbackground="'+ar[++i]+'"'); continue; } - if (ar[i]==BGBACKGROUND) { eval(pf+'bgbackground="'+ar[++i]+'"'); continue; } - if (ar[i]==PADX) { eval(pf+'padxl='+ar[++i]); eval(pf+'padxr='+ar[++i]); continue; } - if (ar[i]==PADY) { eval(pf+'padyt='+ar[++i]); eval(pf+'padyb='+ar[++i]); continue; } - if (ar[i]==FULLHTML) { if (pf!='ol_') eval(pf+'fullhtml=1'); continue; } - if (ar[i]==BELOW || ar[i]==ABOVE) { eval(pf+'vpos='+ar[i]); if (pf!='ol_') olVautoFlag=1; continue; } - if (ar[i]==CAPICON) { eval(pf+'capicon="'+ar[++i]+'"'); continue; } - if (ar[i]==TEXTFONT) { eval(pf+"textfont='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==CAPTIONFONT) { eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==CLOSEFONT) { eval(pf+"closefont='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==TEXTSIZE) { eval(pf+'textsize="'+ar[++i]+'"'); continue; } - if (ar[i]==CAPTIONSIZE) { eval(pf+'captionsize="'+ar[++i]+'"'); continue; } - if (ar[i]==CLOSESIZE) { eval(pf+'closesize="'+ar[++i]+'"'); continue; } - if (ar[i]==TIMEOUT) { eval(pf+'timeout='+ar[++i]); continue; } - if (ar[i]==FUNCTION) { if (pf=='ol_') { if (typeof ar[i+1]!='number') { v=ar[++i]; ol_function=(typeof v=='function' ? v : null); }} else {fnMark = 0; v = null; if (typeof ar[i+1]!='number') v = ar[++i]; opt_FUNCTION(v); } continue; } - if (ar[i]==DELAY) { eval(pf+'delay='+ar[++i]); continue; } - if (ar[i]==HAUTO) { eval(pf+'hauto=('+pf+'hauto == 0) ? 1 : 0'); continue; } - if (ar[i]==VAUTO) { eval(pf+'vauto=('+pf+'vauto == 0) ? 1 : 0'); continue; } - if (ar[i]==CLOSECLICK) { eval(pf +'closeclick=('+pf+'closeclick == 0) ? 1 : 0'); continue; } - if (ar[i]==WRAP) { eval(pf +'wrap=('+pf+'wrap == 0) ? 1 : 0'); continue; } - if (ar[i]==FOLLOWMOUSE) { eval(pf +'followmouse=('+pf+'followmouse == 1) ? 0 : 1'); continue; } - if (ar[i]==MOUSEOFF) { eval(pf +'mouseoff=('+pf+'mouseoff==0) ? 1 : 0'); v=ar[i+1]; if (pf != 'ol_' && eval(pf+'mouseoff') && typeof v == 'number' && (v < pmStart || v > pmUpper)) olHideDelay=ar[++i]; continue; } - if (ar[i]==CLOSETITLE) { eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'"); continue; } - if (ar[i]==CSSOFF||ar[i]==CSSCLASS) { eval(pf+'css='+ar[i]); continue; } - if (ar[i]==COMPATMODE) { eval(pf+'compatmode=('+pf+'compatmode==0) ? 1 : 0'); continue; } - if (ar[i]==FGCLASS) { eval(pf+'fgclass="'+ar[++i]+'"'); continue; } - if (ar[i]==BGCLASS) { eval(pf+'bgclass="'+ar[++i]+'"'); continue; } - if (ar[i]==TEXTFONTCLASS) { eval(pf+'textfontclass="'+ar[++i]+'"'); continue; } - if (ar[i]==CAPTIONFONTCLASS) { eval(pf+'captionfontclass="'+ar[++i]+'"'); continue; } - if (ar[i]==CLOSEFONTCLASS) { eval(pf+'closefontclass="'+ar[++i]+'"'); continue; } - i = parseCmdLine(pf, i, ar); - } - } - - if (fnMark && o3_function) o3_text = o3_function(); - - if ((pf == 'o3_') && o3_wrap) { - o3_width = 0; - - var tReg=/<.*\n*>/ig; - if (!tReg.test(o3_text)) o3_text = o3_text.replace(/[ ]+/g, ' '); - if (!tReg.test(o3_cap))o3_cap = o3_cap.replace(/[ ]+/g, ' '); - } - if ((pf == 'o3_') && o3_sticky) { - if (!o3_close && (o3_frame != ol_frame)) o3_close = ol_close; - if (o3_mouseoff && (o3_frame == ol_frame)) opt_NOCLOSE(' '); - } -} - - -//////// -// LAYER FUNCTIONS -//////// - -// Writes to a layer -function layerWrite(txt) { - txt += "\n"; - if (olNs4) { - var lyr = o3_frame.document.layers['overDiv'].document - lyr.write(txt) - lyr.close() - } else if (typeof over.innerHTML != 'undefined') { - if (olIe5 && isMac) over.innerHTML = ''; - over.innerHTML = txt; - } else { - range = o3_frame.document.createRange(); - range.setStartAfter(over); - domfrag = range.createContextualFragment(txt); - - while (over.hasChildNodes()) { - over.removeChild(over.lastChild); - } - - over.appendChild(domfrag); - } -} - -// Make an object visible -function showObject(obj) { - runHook("showObject", FBEFORE); - - var theObj=(olNs4 ? obj : obj.style); - theObj.visibility = 'visible'; - - runHook("showObject", FAFTER); -} - -// Hides an object -function hideObject(obj) { - runHook("hideObject", FBEFORE); - - var theObj=(olNs4 ? obj : obj.style); - if (olNs6 && olShowId>0) { clearTimeout(olShowId); olShowId=0; } - theObj.visibility = 'hidden'; - theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0); - - if (o3_timerid > 0) clearTimeout(o3_timerid); - if (o3_delayid > 0) clearTimeout(o3_delayid); - - o3_timerid = 0; - o3_delayid = 0; - self.status = ""; - - if (obj.onmouseout||obj.onmouseover) { - if (olNs4) obj.releaseEvents(Event.MOUSEOUT || Event.MOUSEOVER); - obj.onmouseout = obj.onmouseover = null; - } - - runHook("hideObject", FAFTER); -} - -// Move a layer -function repositionTo(obj, xL, yL) { - var theObj=(olNs4 ? obj : obj.style); - theObj.left = xL + (!olNs4 ? 'px' : 0); - theObj.top = yL + (!olNs4 ? 'px' : 0); -} - -// Check position of cursor relative to overDiv DIVision; mouseOut function -function cursorOff() { - var left = parseInt(over.style.left); - var top = parseInt(over.style.top); - var right = left + (over.offsetWidth >= parseInt(o3_width) ? over.offsetWidth : parseInt(o3_width)); - var bottom = top + (over.offsetHeight >= o3_aboveheight ? over.offsetHeight : o3_aboveheight); - - if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true; - - return false; -} - - -//////// -// COMMAND FUNCTIONS -//////// - -// Calls callme or the default function. -function opt_FUNCTION(callme) { - o3_text = (callme ? (typeof callme=='string' ? (/.+\(.*\)/.test(callme) ? eval(callme) : callme) : callme()) : (o3_function ? o3_function() : 'No Function')); - - return 0; -} - -// Handle hovering -function opt_NOCLOSE(unused) { - if (!unused) o3_close = ""; - - if (olNs4) { - over.captureEvents(Event.MOUSEOUT || Event.MOUSEOVER); - over.onmouseover = function () { if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid = 0; } } - over.onmouseout = function (e) { if (olHideDelay) hideDelay(olHideDelay); else cClick(e); } - } else { - over.onmouseover = function () {hoveringSwitch = true; if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid =0; } } - } - - return 0; -} - -// Function to scan command line arguments for multiples -function opt_MULTIPLEARGS(i, args, parameter) { - var k=i, re, pV, str=''; - - for(k=i; kpmStart) break; - str += args[k] + ','; - } - if (str) str = str.substring(0,--str.length); - - k--; // reduce by one so the for loop this is in works correctly - pV=(olNs4 && /cellpad/i.test(parameter)) ? str.split(',')[0] : str; - eval(parameter + '="' + pV + '"'); - - return k; -} - -// Remove   in texts when done. -function nbspCleanup() { - if (o3_wrap) { - o3_text = o3_text.replace(/\ /g, ' '); - o3_cap = o3_cap.replace(/\ /g, ' '); - } -} - -// Escape embedded single quotes in text strings -function escSglQuote(str) { - return str.toString().replace(/'/g,"\\'"); -} - -// Onload handler for window onload event -function OLonLoad_handler(e) { - var re = /\w+\(.*\)[;\s]+/g, olre = /overlib\(|nd\(|cClick\(/, fn, l, i; - - if(!olLoaded) olLoaded=1; - - // Remove it for Gecko based browsers - if(window.removeEventListener && e.eventPhase == 3) window.removeEventListener("load",OLonLoad_handler,false); - else if(window.detachEvent) { // and for IE and Opera 4.x but execute calls to overlib, nd, or cClick() - window.detachEvent("onload",OLonLoad_handler); - var fN = document.body.getAttribute('onload'); - if (fN) { - fN=fN.toString().match(re); - if (fN && fN.length) { - for (i=0; i' : '') : ''; - else { - fontStr='o3_'+whichString+'font'; - fontColor='o3_'+((whichString=='caption')? 'cap' : whichString)+'color'; - return (hasDims&&!olNs4) ? (isClose ? '' : '
') : ''; - } -} - -// Quotes Multi word font names; needed for CSS Standards adherence in font-family -function quoteMultiNameFonts(theFont) { - var v, pM=theFont.split(','); - for (var i=0; i 0) clearTimeout(o3_timerid); - - o3_timerid=setTimeout("cClick()",(o3_timeout=time)); - } -} - -// Was originally in the placeLayer() routine; separated out for future ease -function horizontalPlacement(browserWidth, horizontalScrollAmount, widthFix) { - var placeX, iwidth=browserWidth, winoffset=horizontalScrollAmount; - var parsedWidth = parseInt(o3_width); - - if (o3_fixx > -1 || o3_relx != null) { - // Fixed position - placeX=(o3_relx != null ? ( o3_relx < 0 ? winoffset +o3_relx+ iwidth - parsedWidth - widthFix : winoffset+o3_relx) : o3_fixx); - } else { - // If HAUTO, decide what to use. - if (o3_hauto == 1) { - if ((o3_x - winoffset) > (iwidth / 2)) { - o3_hpos = LEFT; - } else { - o3_hpos = RIGHT; - } - } - - // From mouse - if (o3_hpos == CENTER) { // Center - placeX = o3_x+o3_offsetx-(parsedWidth/2); - - if (placeX < winoffset) placeX = winoffset; - } - - if (o3_hpos == RIGHT) { // Right - placeX = o3_x+o3_offsetx; - - if ((placeX+parsedWidth) > (winoffset+iwidth - widthFix)) { - placeX = iwidth+winoffset - parsedWidth - widthFix; - if (placeX < 0) placeX = 0; - } - } - if (o3_hpos == LEFT) { // Left - placeX = o3_x-o3_offsetx-parsedWidth; - if (placeX < winoffset) placeX = winoffset; - } - - // Snapping! - if (o3_snapx > 1) { - var snapping = placeX % o3_snapx; - - if (o3_hpos == LEFT) { - placeX = placeX - (o3_snapx+snapping); - } else { - // CENTER and RIGHT - placeX = placeX+(o3_snapx - snapping); - } - - if (placeX < winoffset) placeX = winoffset; - } - } - - return placeX; -} - -// was originally in the placeLayer() routine; separated out for future ease -function verticalPlacement(browserHeight,verticalScrollAmount) { - var placeY, iheight=browserHeight, scrolloffset=verticalScrollAmount; - var parsedHeight=(o3_aboveheight ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)); - - if (o3_fixy > -1 || o3_rely != null) { - // Fixed position - placeY=(o3_rely != null ? (o3_rely < 0 ? scrolloffset+o3_rely+iheight - parsedHeight : scrolloffset+o3_rely) : o3_fixy); - } else { - // If VAUTO, decide what to use. - if (o3_vauto == 1) { - if ((o3_y - scrolloffset) > (iheight / 2) && o3_vpos == BELOW && (o3_y + parsedHeight + o3_offsety - (scrolloffset + iheight) > 0)) { - o3_vpos = ABOVE; - } else if (o3_vpos == ABOVE && (o3_y - (parsedHeight + o3_offsety) - scrolloffset < 0)) { - o3_vpos = BELOW; - } - } - - // From mouse - if (o3_vpos == ABOVE) { - if (o3_aboveheight == 0) o3_aboveheight = parsedHeight; - - placeY = o3_y - (o3_aboveheight+o3_offsety); - if (placeY < scrolloffset) placeY = scrolloffset; - } else { - // BELOW - placeY = o3_y+o3_offsety; - } - - // Snapping! - if (o3_snapy > 1) { - var snapping = placeY % o3_snapy; - - if (o3_aboveheight > 0 && o3_vpos == ABOVE) { - placeY = placeY - (o3_snapy+snapping); - } else { - placeY = placeY+(o3_snapy - snapping); - } - - if (placeY < scrolloffset) placeY = scrolloffset; - } - } - - return placeY; -} - -// checks positioning flags -function checkPositionFlags() { - if (olHautoFlag) olHautoFlag = o3_hauto=0; - if (olVautoFlag) olVautoFlag = o3_vauto=0; - return true; -} - -// get Browser window width -function windowWidth() { - var w; - if (o3_frame.innerWidth) w=o3_frame.innerWidth; - else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) - w=eval('o3_frame.'+docRoot+'.clientWidth'); - return w; -} - -// create the div container for popup content if it doesn't exist -function createDivContainer(id,frm,zValue) { - id = (id || 'overDiv'), frm = (frm || o3_frame), zValue = (zValue || 1000); - var objRef, divContainer = layerReference(id); - - if (divContainer == null) { - if (olNs4) { - divContainer = frm.document.layers[id] = new Layer(window.innerWidth, frm); - objRef = divContainer; - } else { - var body = (olIe4 ? frm.document.all.tags('BODY')[0] : frm.document.getElementsByTagName("BODY")[0]); - if (olIe4&&!document.getElementById) { - body.insertAdjacentHTML("beforeEnd",'
'); - divContainer=layerReference(id); - } else { - divContainer = frm.document.createElement("DIV"); - divContainer.id = id; - body.appendChild(divContainer); - } - objRef = divContainer.style; - } - - objRef.position = 'absolute'; - objRef.visibility = 'hidden'; - objRef.zIndex = zValue; - if (olIe4&&!olOp) objRef.left = objRef.top = '0px'; - else objRef.left = objRef.top = -10000 + (!olNs4 ? 'px' : 0); - } - - return divContainer; -} - -// get reference to a layer with ID=id -function layerReference(id) { - return (olNs4 ? o3_frame.document.layers[id] : (document.all ? o3_frame.document.all[id] : o3_frame.document.getElementById(id))); -} -//////// -// UTILITY FUNCTIONS -//////// - -// Checks if something is a function. -function isFunction(fnRef) { - var rtn = true; - - if (typeof fnRef == 'object') { - for (var i = 0; i < fnRef.length; i++) { - if (typeof fnRef[i]=='function') continue; - rtn = false; - break; - } - } else if (typeof fnRef != 'function') { - rtn = false; - } - - return rtn; -} - -// Converts an array into an argument string for use in eval. -function argToString(array, strtInd, argName) { - var jS = strtInd, aS = '', ar = array; - argName=(argName ? argName : 'ar'); - - if (ar.length > jS) { - for (var k = jS; k < ar.length; k++) aS += argName+'['+k+'], '; - aS = aS.substring(0, aS.length-2); - } - - return aS; -} - -// Places a hook in the correct position in a hook point. -function reOrder(hookPt, fnRef, order) { - var newPt = new Array(), match, i, j; - - if (!order || typeof order == 'undefined' || typeof order == 'number') return hookPt; - - if (typeof order=='function') { - if (typeof fnRef=='object') { - newPt = newPt.concat(fnRef); - } else { - newPt[newPt.length++]=fnRef; - } - - for (i = 0; i < hookPt.length; i++) { - match = false; - if (typeof fnRef == 'function' && hookPt[i] == fnRef) { - continue; - } else { - for(j = 0; j < fnRef.length; j++) if (hookPt[i] == fnRef[j]) { - match = true; - break; - } - } - if (!match) newPt[newPt.length++] = hookPt[i]; - } - - newPt[newPt.length++] = order; - - } else if (typeof order == 'object') { - if (typeof fnRef == 'object') { - newPt = newPt.concat(fnRef); - } else { - newPt[newPt.length++] = fnRef; - } - - for (j = 0; j < hookPt.length; j++) { - match = false; - if (typeof fnRef == 'function' && hookPt[j] == fnRef) { - continue; - } else { - for (i = 0; i < fnRef.length; i++) if (hookPt[j] == fnRef[i]) { - match = true; - break; - } - } - if (!match) newPt[newPt.length++]=hookPt[j]; - } - - for (i = 0; i < newPt.length; i++) hookPt[i] = newPt[i]; - newPt.length = 0; - - for (j = 0; j < hookPt.length; j++) { - match = false; - for (i = 0; i < order.length; i++) { - if (hookPt[j] == order[i]) { - match = true; - break; - } - } - if (!match) newPt[newPt.length++] = hookPt[j]; - } - newPt = newPt.concat(order); - } - - hookPt = newPt; - - return hookPt; -} - -//////// -// PLUGIN ACTIVATION FUNCTIONS -//////// - -// Runs plugin functions to set runtime variables. -function setRunTimeVariables(){ - if (typeof runTime != 'undefined' && runTime.length) { - for (var k = 0; k < runTime.length; k++) { - runTime[k](); - } - } -} - -// Runs plugin functions to parse commands. -function parseCmdLine(pf, i, args) { - if (typeof cmdLine != 'undefined' && cmdLine.length) { - for (var k = 0; k < cmdLine.length; k++) { - var j = cmdLine[k](pf, i, args); - if (j >- 1) { - i = j; - break; - } - } - } - - return i; -} - -// Runs plugin functions to do things after parse. -function postParseChecks(pf,args){ - if (typeof postParse != 'undefined' && postParse.length) { - for (var k = 0; k < postParse.length; k++) { - if (postParse[k](pf,args)) continue; - return false; // end now since have an error - } - } - return true; -} - - -//////// -// PLUGIN REGISTRATION FUNCTIONS -//////// - -// Registers commands and creates constants. -function registerCommands(cmdStr) { - if (typeof cmdStr!='string') return; - - var pM = cmdStr.split(','); - pms = pms.concat(pM); - - for (var i = 0; i< pM.length; i++) { - eval(pM[i].toUpperCase()+'='+pmCount++); - } -} - -// Registers no-parameter commands -function registerNoParameterCommands(cmdStr) { - if (!cmdStr && typeof cmdStr != 'string') return; - pmt=(!pmt) ? cmdStr : pmt + ',' + cmdStr; -} - -// Register a function to hook at a certain point. -function registerHook(fnHookTo, fnRef, hookType, optPm) { - var hookPt, last = typeof optPm; - - if (fnHookTo == 'plgIn'||fnHookTo == 'postParse') return; - if (typeof hookPts[fnHookTo] == 'undefined') hookPts[fnHookTo] = new FunctionReference(); - - hookPt = hookPts[fnHookTo]; - - if (hookType != null) { - if (hookType == FREPLACE) { - hookPt.ovload = fnRef; // replace normal overlib routine - if (fnHookTo.indexOf('ol_content_') > -1) hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; - - } else if (hookType == FBEFORE || hookType == FAFTER) { - var hookPt=(hookType == 1 ? hookPt.before : hookPt.after); - - if (typeof fnRef == 'object') { - hookPt = hookPt.concat(fnRef); - } else { - hookPt[hookPt.length++] = fnRef; - } - - if (optPm) hookPt = reOrder(hookPt, fnRef, optPm); - - } else if (hookType == FALTERNATE) { - if (last=='number') hookPt.alt[pms[optPm-1-pmStart]] = fnRef; - } else if (hookType == FCHAIN) { - hookPt = hookPt.chain; - if (typeof fnRef=='object') hookPt=hookPt.concat(fnRef); // add other functions - else hookPt[hookPt.length++]=fnRef; - } - - return; - } -} - -// Register a function that will set runtime variables. -function registerRunTimeFunction(fn) { - if (isFunction(fn)) { - if (typeof fn == 'object') { - runTime = runTime.concat(fn); - } else { - runTime[runTime.length++] = fn; - } - } -} - -// Register a function that will handle command parsing. -function registerCmdLineFunction(fn){ - if (isFunction(fn)) { - if (typeof fn == 'object') { - cmdLine = cmdLine.concat(fn); - } else { - cmdLine[cmdLine.length++] = fn; - } - } -} - -// Register a function that does things after command parsing. -function registerPostParseFunction(fn){ - if (isFunction(fn)) { - if (typeof fn == 'object') { - postParse = postParse.concat(fn); - } else { - postParse[postParse.length++] = fn; - } - } -} - -//////// -// PLUGIN REGISTRATION FUNCTIONS -//////// - -// Runs any hooks registered. -function runHook(fnHookTo, hookType) { - var l = hookPts[fnHookTo], k, rtnVal = null, optPm, arS, ar = runHook.arguments; - - if (hookType == FREPLACE) { - arS = argToString(ar, 2); - - if (typeof l == 'undefined' || !(l = l.ovload)) rtnVal = eval(fnHookTo+'('+arS+')'); - else rtnVal = eval('l('+arS+')'); - - } else if (hookType == FBEFORE || hookType == FAFTER) { - if (typeof l != 'undefined') { - l=(hookType == 1 ? l.before : l.after); - - if (l.length) { - arS = argToString(ar, 2); - for (var k = 0; k < l.length; k++) eval('l[k]('+arS+')'); - } - } - } else if (hookType == FALTERNATE) { - optPm = ar[2]; - arS = argToString(ar, 3); - - if (typeof l == 'undefined' || (l = l.alt[pms[optPm-1-pmStart]]) == 'undefined') { - rtnVal = eval(fnHookTo+'('+arS+')'); - } else { - rtnVal = eval('l('+arS+')'); - } - } else if (hookType == FCHAIN) { - arS=argToString(ar,2); - l=l.chain; - - for (k=l.length; k > 0; k--) if((rtnVal=eval('l[k-1]('+arS+')'))!=void(0)) break; - } - - return rtnVal; -} - -//////// -// OBJECT CONSTRUCTORS -//////// - -// Object for handling hooks. -function FunctionReference() { - this.ovload = null; - this.before = new Array(); - this.after = new Array(); - this.alt = new Array(); - this.chain = new Array(); -} - -// Object for simple access to the overLIB version used. -// Examples: simpleversion:351 major:3 minor:5 revision:1 -function Info(version, prerelease) { - this.version = version; - this.prerelease = prerelease; - - this.simpleversion = Math.round(this.version*100); - this.major = parseInt(this.simpleversion / 100); - this.minor = parseInt(this.simpleversion / 10) - this.major * 10; - this.revision = parseInt(this.simpleversion) - this.major * 100 - this.minor * 10; - this.meets = meets; -} - -// checks for Core Version required -function meets(reqdVersion) { - return (!reqdVersion) ? false : this.simpleversion >= Math.round(100*parseFloat(reqdVersion)); -} - - -//////// -// STANDARD REGISTRATIONS -//////// -registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSOFF); -registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSOFF); -registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSOFF); -registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSCLASS); -registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSCLASS); -registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSCLASS); -registerPostParseFunction(checkPositionFlags); -registerHook("hideObject", nbspCleanup, FAFTER); -registerHook("horizontalPlacement", horizontalPlacement, FCHAIN); -registerHook("verticalPlacement", verticalPlacement, FCHAIN); -if (olNs4||(olIe5&&isMac)||olKq) olLoaded=1; -registerNoParameterCommands('sticky,autostatus,autostatuscap,fullhtml,hauto,vauto,closeclick,wrap,followmouse,mouseoff,compatmode'); -/////// -// ESTABLISH MOUSECAPTURING -/////// - -// Capture events, alt. diffuses the overlib function. -var olCheckMouseCapture=true; -if ((olNs4 || olNs6 || olIe4)) { - olMouseCapture(); -} else { - overlib = no_overlib; - nd = no_overlib; - ver3fix = true; -} +//\///// +//\ overLIB 4.21 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ +//\ Contributors are listed on the homepage. +//\ This file might be old, always check for the latest version at: +//\ http://www.bosrup.com/web/overlib/ +//\ +//\ Please read the license agreement (available through the link above) +//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. +//\ +//\ Do not sell this as your own work or remove this copyright notice. +//\ For full details on copying or changing this script please read the +//\ license agreement at the link above. Please give credit on sites that +//\ use overLIB and submit changes of the script so other people can use +//\ them as well. +// $Revision: 1.1 $ $Date: 2006/05/29 16:38:21 $ +//\///// +//\mini + +//////// +// PRE-INIT +// Ignore these lines, configuration is below. +//////// +var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1; var pmt=''; var pms = new Array(); var olInfo = new Info('4.21', 1); +var FREPLACE = 0; var FBEFORE = 1; var FAFTER = 2; var FALTERNATE = 3; var FCHAIN=4; +var olHideForm=0; // parameter for hiding SELECT and ActiveX elements in IE5.5+ +var olHautoFlag = 0; // flags for over-riding VAUTO and HAUTO if corresponding +var olVautoFlag = 0; // positioning commands are used on the command line +var hookPts = new Array(), postParse = new Array(), cmdLine = new Array(), runTime = new Array(); +// for plugins +registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass'); + +//////// +// DEFAULT CONFIGURATION +// Settings you want everywhere are set here. All of this can also be +// changed on your html page or through an overLIB call. +//////// +if (typeof ol_fgcolor=='undefined') var ol_fgcolor="#99BBDD"; +if (typeof ol_bgcolor=='undefined') var ol_bgcolor="#7799BB"; +if (typeof ol_textcolor=='undefined') var ol_textcolor="#000000"; +if (typeof ol_capcolor=='undefined') var ol_capcolor="#000033"; +if (typeof ol_closecolor=='undefined') var ol_closecolor="#000000"; +if (typeof ol_textfont=='undefined') var ol_textfont="Verdana,Arial,Helvetica"; +if (typeof ol_captionfont=='undefined') var ol_captionfont="Verdana,Arial,Helvetica"; +if (typeof ol_closefont=='undefined') var ol_closefont="Verdana,Arial,Helvetica"; +if (typeof ol_textsize=='undefined') var ol_textsize="1"; +if (typeof ol_captionsize=='undefined') var ol_captionsize="1"; +if (typeof ol_closesize=='undefined') var ol_closesize="1"; +if (typeof ol_width=='undefined') var ol_width="200"; +if (typeof ol_border=='undefined') var ol_border="1"; +if (typeof ol_cellpad=='undefined') var ol_cellpad=2; +if (typeof ol_offsetx=='undefined') var ol_offsetx=10; +if (typeof ol_offsety=='undefined') var ol_offsety=10; +if (typeof ol_text=='undefined') var ol_text="Default Text"; +if (typeof ol_cap=='undefined') var ol_cap=""; +if (typeof ol_sticky=='undefined') var ol_sticky=0; +if (typeof ol_background=='undefined') var ol_background=""; +if (typeof ol_close=='undefined') var ol_close="Close"; +if (typeof ol_hpos=='undefined') var ol_hpos=RIGHT; +if (typeof ol_status=='undefined') var ol_status=""; +if (typeof ol_autostatus=='undefined') var ol_autostatus=0; +if (typeof ol_height=='undefined') var ol_height=-1; +if (typeof ol_snapx=='undefined') var ol_snapx=0; +if (typeof ol_snapy=='undefined') var ol_snapy=0; +if (typeof ol_fixx=='undefined') var ol_fixx=-1; +if (typeof ol_fixy=='undefined') var ol_fixy=-1; +if (typeof ol_relx=='undefined') var ol_relx=null; +if (typeof ol_rely=='undefined') var ol_rely=null; +if (typeof ol_fgbackground=='undefined') var ol_fgbackground=""; +if (typeof ol_bgbackground=='undefined') var ol_bgbackground=""; +if (typeof ol_padxl=='undefined') var ol_padxl=1; +if (typeof ol_padxr=='undefined') var ol_padxr=1; +if (typeof ol_padyt=='undefined') var ol_padyt=1; +if (typeof ol_padyb=='undefined') var ol_padyb=1; +if (typeof ol_fullhtml=='undefined') var ol_fullhtml=0; +if (typeof ol_vpos=='undefined') var ol_vpos=BELOW; +if (typeof ol_aboveheight=='undefined') var ol_aboveheight=0; +if (typeof ol_capicon=='undefined') var ol_capicon=""; +if (typeof ol_frame=='undefined') var ol_frame=self; +if (typeof ol_timeout=='undefined') var ol_timeout=0; +if (typeof ol_function=='undefined') var ol_function=null; +if (typeof ol_delay=='undefined') var ol_delay=0; +if (typeof ol_hauto=='undefined') var ol_hauto=0; +if (typeof ol_vauto=='undefined') var ol_vauto=0; +if (typeof ol_closeclick=='undefined') var ol_closeclick=0; +if (typeof ol_wrap=='undefined') var ol_wrap=0; +if (typeof ol_followmouse=='undefined') var ol_followmouse=1; +if (typeof ol_mouseoff=='undefined') var ol_mouseoff=0; +if (typeof ol_closetitle=='undefined') var ol_closetitle='Close'; +if (typeof ol_compatmode=='undefined') var ol_compatmode=0; +if (typeof ol_css=='undefined') var ol_css=CSSOFF; +if (typeof ol_fgclass=='undefined') var ol_fgclass=""; +if (typeof ol_bgclass=='undefined') var ol_bgclass=""; +if (typeof ol_textfontclass=='undefined') var ol_textfontclass=""; +if (typeof ol_captionfontclass=='undefined') var ol_captionfontclass=""; +if (typeof ol_closefontclass=='undefined') var ol_closefontclass=""; + +//////// +// ARRAY CONFIGURATION +//////// + +// You can use these arrays to store popup text here instead of in the html. +if (typeof ol_texts=='undefined') var ol_texts = new Array("Text 0", "Text 1"); +if (typeof ol_caps=='undefined') var ol_caps = new Array("Caption 0", "Caption 1"); + +//////// +// END OF CONFIGURATION +// Don't change anything below this line, all configuration is above. +//////// + + + + + +//////// +// INIT +//////// +// Runtime variables init. Don't change for config! +var o3_text=""; +var o3_cap=""; +var o3_sticky=0; +var o3_background=""; +var o3_close="Close"; +var o3_hpos=RIGHT; +var o3_offsetx=2; +var o3_offsety=2; +var o3_fgcolor=""; +var o3_bgcolor=""; +var o3_textcolor=""; +var o3_capcolor=""; +var o3_closecolor=""; +var o3_width=100; +var o3_border=1; +var o3_cellpad=2; +var o3_status=""; +var o3_autostatus=0; +var o3_height=-1; +var o3_snapx=0; +var o3_snapy=0; +var o3_fixx=-1; +var o3_fixy=-1; +var o3_relx=null; +var o3_rely=null; +var o3_fgbackground=""; +var o3_bgbackground=""; +var o3_padxl=0; +var o3_padxr=0; +var o3_padyt=0; +var o3_padyb=0; +var o3_fullhtml=0; +var o3_vpos=BELOW; +var o3_aboveheight=0; +var o3_capicon=""; +var o3_textfont="Verdana,Arial,Helvetica"; +var o3_captionfont="Verdana,Arial,Helvetica"; +var o3_closefont="Verdana,Arial,Helvetica"; +var o3_textsize="1"; +var o3_captionsize="1"; +var o3_closesize="1"; +var o3_frame=self; +var o3_timeout=0; +var o3_timerid=0; +var o3_allowmove=0; +var o3_function=null; +var o3_delay=0; +var o3_delayid=0; +var o3_hauto=0; +var o3_vauto=0; +var o3_closeclick=0; +var o3_wrap=0; +var o3_followmouse=1; +var o3_mouseoff=0; +var o3_closetitle=''; +var o3_compatmode=0; +var o3_css=CSSOFF; +var o3_fgclass=""; +var o3_bgclass=""; +var o3_textfontclass=""; +var o3_captionfontclass=""; +var o3_closefontclass=""; + +// Display state variables +var o3_x = 0; +var o3_y = 0; +var o3_showingsticky = 0; +var o3_removecounter = 0; + +// Our layer +var over = null; +var fnRef, hoveringSwitch = false; +var olHideDelay; + +// Decide browser version +var isMac = (navigator.userAgent.indexOf("Mac") != -1); +var olOp = (navigator.userAgent.toLowerCase().indexOf('opera') > -1 && document.createTextNode); // Opera 7 +var olNs4 = (navigator.appName=='Netscape' && parseInt(navigator.appVersion) == 4); +var olNs6 = (document.getElementById) ? true : false; +var olKq = (olNs6 && /konqueror/i.test(navigator.userAgent)); +var olIe4 = (document.all) ? true : false; +var olIe5 = false; +var olIe55 = false; // Added additional variable to identify IE5.5+ +var docRoot = 'document.body'; + +// Resize fix for NS4.x to keep track of layer +if (olNs4) { + var oW = window.innerWidth; + var oH = window.innerHeight; + window.onresize = function() { if (oW != window.innerWidth || oH != window.innerHeight) location.reload(); } +} + +// Microsoft Stupidity Check(tm). +if (olIe4) { + var agent = navigator.userAgent; + if (/MSIE/.test(agent)) { + var versNum = parseFloat(agent.match(/MSIE[ ](\d\.\d+)\.*/i)[1]); + if (versNum >= 5){ + olIe5=true; + olIe55=(versNum>=5.5&&!olOp) ? true : false; + if (olNs6) olNs6=false; + } + } + if (olNs6) olIe4 = false; +} + +// Check for compatability mode. +if (document.compatMode && document.compatMode == 'CSS1Compat') { + docRoot= ((olIe4 && !olOp) ? 'document.documentElement' : docRoot); +} + +// Add window onload handlers to indicate when all modules have been loaded +// For Netscape 6+ and Mozilla, uses addEventListener method on the window object +// For IE it uses the attachEvent method of the window object and for Netscape 4.x +// it sets the window.onload handler to the OLonload_handler function for Bubbling +if(window.addEventListener) window.addEventListener("load",OLonLoad_handler,false); +else if (window.attachEvent) window.attachEvent("onload",OLonLoad_handler); + +var capExtent; + +//////// +// PUBLIC FUNCTIONS +//////// + +// overlib(arg0,...,argN) +// Loads parameters into global runtime variables. +function overlib() { + if (!olLoaded || isExclusive(overlib.arguments)) return true; + if (olCheckMouseCapture) olMouseCapture(); + if (over) { + over = (typeof over.id != 'string') ? o3_frame.document.all['overDiv'] : over; + cClick(); + } + + // Load defaults to runtime. + olHideDelay=0; + o3_text=ol_text; + o3_cap=ol_cap; + o3_sticky=ol_sticky; + o3_background=ol_background; + o3_close=ol_close; + o3_hpos=ol_hpos; + o3_offsetx=ol_offsetx; + o3_offsety=ol_offsety; + o3_fgcolor=ol_fgcolor; + o3_bgcolor=ol_bgcolor; + o3_textcolor=ol_textcolor; + o3_capcolor=ol_capcolor; + o3_closecolor=ol_closecolor; + o3_width=ol_width; + o3_border=ol_border; + o3_cellpad=ol_cellpad; + o3_status=ol_status; + o3_autostatus=ol_autostatus; + o3_height=ol_height; + o3_snapx=ol_snapx; + o3_snapy=ol_snapy; + o3_fixx=ol_fixx; + o3_fixy=ol_fixy; + o3_relx=ol_relx; + o3_rely=ol_rely; + o3_fgbackground=ol_fgbackground; + o3_bgbackground=ol_bgbackground; + o3_padxl=ol_padxl; + o3_padxr=ol_padxr; + o3_padyt=ol_padyt; + o3_padyb=ol_padyb; + o3_fullhtml=ol_fullhtml; + o3_vpos=ol_vpos; + o3_aboveheight=ol_aboveheight; + o3_capicon=ol_capicon; + o3_textfont=ol_textfont; + o3_captionfont=ol_captionfont; + o3_closefont=ol_closefont; + o3_textsize=ol_textsize; + o3_captionsize=ol_captionsize; + o3_closesize=ol_closesize; + o3_timeout=ol_timeout; + o3_function=ol_function; + o3_delay=ol_delay; + o3_hauto=ol_hauto; + o3_vauto=ol_vauto; + o3_closeclick=ol_closeclick; + o3_wrap=ol_wrap; + o3_followmouse=ol_followmouse; + o3_mouseoff=ol_mouseoff; + o3_closetitle=ol_closetitle; + o3_css=ol_css; + o3_compatmode=ol_compatmode; + o3_fgclass=ol_fgclass; + o3_bgclass=ol_bgclass; + o3_textfontclass=ol_textfontclass; + o3_captionfontclass=ol_captionfontclass; + o3_closefontclass=ol_closefontclass; + + setRunTimeVariables(); + + fnRef = ''; + + // Special for frame support, over must be reset... + o3_frame = ol_frame; + + if(!(over=createDivContainer())) return false; + + parseTokens('o3_', overlib.arguments); + if (!postParseChecks()) return false; + + if (o3_delay == 0) { + return runHook("olMain", FREPLACE); + } else { + o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay); + return false; + } +} + +// Clears popups if appropriate +function nd(time) { + if (olLoaded && !isExclusive()) { + hideDelay(time); // delay popup close if time specified + + if (o3_removecounter >= 1) { o3_showingsticky = 0 }; + + if (o3_showingsticky == 0) { + o3_allowmove = 0; + if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over); + } else { + o3_removecounter++; + } + } + + return true; +} + +// The Close onMouseOver function for stickies +function cClick() { + if (olLoaded) { + runHook("hideObject", FREPLACE, over); + o3_showingsticky = 0; + } + return false; +} + +// Method for setting page specific defaults. +function overlib_pagedefaults() { + parseTokens('ol_', overlib_pagedefaults.arguments); +} + + +//////// +// OVERLIB MAIN FUNCTION +//////// + +// This function decides what it is we want to display and how we want it done. +function olMain() { + var layerhtml, styleType; + runHook("olMain", FBEFORE); + + if (o3_background!="" || o3_fullhtml) { + // Use background instead of box. + layerhtml = runHook('ol_content_background', FALTERNATE, o3_css, o3_text, o3_background, o3_fullhtml); + } else { + // They want a popup box. + styleType = (pms[o3_css-1-pmStart] == "cssoff" || pms[o3_css-1-pmStart] == "cssclass"); + + // Prepare popup background + if (o3_fgbackground != "") o3_fgbackground = "background=\""+o3_fgbackground+"\""; + if (o3_bgbackground != "") o3_bgbackground = (styleType ? "background=\""+o3_bgbackground+"\"" : o3_bgbackground); + + // Prepare popup colors + if (o3_fgcolor != "") o3_fgcolor = (styleType ? "bgcolor=\""+o3_fgcolor+"\"" : o3_fgcolor); + if (o3_bgcolor != "") o3_bgcolor = (styleType ? "bgcolor=\""+o3_bgcolor+"\"" : o3_bgcolor); + + // Prepare popup height + if (o3_height > 0) o3_height = (styleType ? "height=\""+o3_height+"\"" : o3_height); + else o3_height = ""; + + // Decide which kinda box. + if (o3_cap=="") { + // Plain + layerhtml = runHook('ol_content_simple', FALTERNATE, o3_css, o3_text); + } else { + // With caption + if (o3_sticky) { + // Show close text + layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close); + } else { + // No close text + layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, ""); + } + } + } + + // We want it to stick! + if (o3_sticky) { + if (o3_timerid > 0) { + clearTimeout(o3_timerid); + o3_timerid = 0; + } + o3_showingsticky = 1; + o3_removecounter = 0; + } + + // Created a separate routine to generate the popup to make it easier + // to implement a plugin capability + if (!runHook("createPopup", FREPLACE, layerhtml)) return false; + + // Prepare status bar + if (o3_autostatus > 0) { + o3_status = o3_text; + if (o3_autostatus > 1) o3_status = o3_cap; + } + + // When placing the layer the first time, even stickies may be moved. + o3_allowmove = 0; + + // Initiate a timer for timeout + if (o3_timeout > 0) { + if (o3_timerid > 0) clearTimeout(o3_timerid); + o3_timerid = setTimeout("cClick()", o3_timeout); + } + + // Show layer + runHook("disp", FREPLACE, o3_status); + runHook("olMain", FAFTER); + + return (olOp && event && event.type == 'mouseover' && !o3_status) ? '' : (o3_status != ''); +} + +//////// +// LAYER GENERATION FUNCTIONS +//////// +// These functions just handle popup content with tags that should adhere to the W3C standards specification. + +// Makes simple table without caption +function ol_content_simple(text) { + var cpIsMultiple = /,/.test(o3_cellpad); + var txt = '
' : ((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'
'; + + set_background(""); + return txt; +} + +// Makes table with caption and optional close link +function ol_content_caption(text,title,close) { + var nameId, txt, cpIsMultiple = /,/.test(o3_cellpad); + var closing, closeevent; + + closing = ""; + closeevent = "onmouseover"; + if (o3_closeclick == 1) closeevent = (o3_closetitle ? "title='" + o3_closetitle +"'" : "") + " onclick"; + if (o3_capicon != "") { + nameId = ' hspace = \"5\"'+' align = \"middle\" alt = \"\"'; + if (typeof o3_dragimg != 'undefined' && o3_dragimg) nameId =' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"'; + o3_capicon = ''; + } + + if (close != "") + closing = ''+(o3_closefontclass ? '' : wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass ? '' : wrapStr(1,o3_closesize,'close'))+''; + txt = '
' : '>')+(o3_captionfontclass ? '' : ''+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass ? '' : wrapStr(1,o3_captionsize)+'')+''+closing+'
' :((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize)) + '
'; + + set_background(""); + return txt; +} + +// Sets the background picture,padding and lots more. :) +function ol_content_background(text,picture,hasfullhtml) { + if (hasfullhtml) { + txt=text; + } else { + txt='
'+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'
'; + } + + set_background(picture); + return txt; +} + +// Loads a picture into the div. +function set_background(pic) { + if (pic == "") { + if (olNs4) { + over.background.src = null; + } else if (over.style) { + over.style.backgroundImage = "none"; + } + } else { + if (olNs4) { + over.background.src = pic; + } else if (over.style) { + over.style.width=o3_width + 'px'; + over.style.backgroundImage = "url("+pic+")"; + } + } +} + +//////// +// HANDLING FUNCTIONS +//////// +var olShowId=-1; + +// Displays the popup +function disp(statustext) { + runHook("disp", FBEFORE); + + if (o3_allowmove == 0) { + runHook("placeLayer", FREPLACE); + (olNs6&&olShowId<0) ? olShowId=setTimeout("runHook('showObject', FREPLACE, over)", 1) : runHook("showObject", FREPLACE, over); + o3_allowmove = (o3_sticky || o3_followmouse==0) ? 0 : 1; + } + + runHook("disp", FAFTER); + + if (statustext != "") self.status = statustext; +} + +// Creates the actual popup structure +function createPopup(lyrContent){ + runHook("createPopup", FBEFORE); + + if (o3_wrap) { + var wd,ww,theObj = (olNs4 ? over : over.style); + theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0); + layerWrite(lyrContent); + wd = (olNs4 ? over.clip.width : over.offsetWidth); + if (wd > (ww=windowWidth())) { + lyrContent=lyrContent.replace(/\ /g, ' '); + o3_width=ww; + o3_wrap=0; + } + } + + layerWrite(lyrContent); + + // Have to set o3_width for placeLayer() routine if o3_wrap is turned on + if (o3_wrap) o3_width=(olNs4 ? over.clip.width : over.offsetWidth); + + runHook("createPopup", FAFTER, lyrContent); + + return true; +} + +// Decides where we want the popup. +function placeLayer() { + var placeX, placeY, widthFix = 0; + + // HORIZONTAL PLACEMENT, re-arranged to work in Safari + if (o3_frame.innerWidth) widthFix=18; + iwidth = windowWidth(); + + // Horizontal scroll offset + winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset; + + placeX = runHook('horizontalPlacement',FCHAIN,iwidth,winoffset,widthFix); + + // VERTICAL PLACEMENT, re-arranged to work in Safari + if (o3_frame.innerHeight) { + iheight=o3_frame.innerHeight; + } else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientHeight=='number'")&&eval('o3_frame.'+docRoot+'.clientHeight')) { + iheight=eval('o3_frame.'+docRoot+'.clientHeight'); + } + + // Vertical scroll offset + scrolloffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollTop') : o3_frame.pageYOffset; + placeY = runHook('verticalPlacement',FCHAIN,iheight,scrolloffset); + + // Actually move the object. + repositionTo(over, placeX, placeY); +} + +// Moves the layer +function olMouseMove(e) { + var e = (e) ? e : event; + + if (e.pageX) { + o3_x = e.pageX; + o3_y = e.pageY; + } else if (e.clientX) { + o3_x = eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft'); + o3_y = eval('e.clientY+o3_frame.'+docRoot+'.scrollTop'); + } + + if (o3_allowmove == 1) runHook("placeLayer", FREPLACE); + + // MouseOut handler + if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) { + (olHideDelay ? hideDelay(olHideDelay) : cClick()); + hoveringSwitch = !hoveringSwitch; + } +} + +// Fake function for 3.0 users. +function no_overlib() { return ver3fix; } + +// Capture the mouse and chain other scripts. +function olMouseCapture() { + capExtent = document; + var fN, str = '', l, k, f, wMv, sS, mseHandler = olMouseMove; + var re = /function[ ]*(\w*)\(/; + + wMv = (!olIe4 && window.onmousemove); + if (document.onmousemove || wMv) { + if (wMv) capExtent = window; + f = capExtent.onmousemove.toString(); + fN = f.match(re); + if (fN == null) { + str = f+'(e); '; + } else if (fN[1] == 'anonymous' || fN[1] == 'olMouseMove' || (wMv && fN[1] == 'onmousemove')) { + if (!olOp && wMv) { + l = f.indexOf('{')+1; + k = f.lastIndexOf('}'); + sS = f.substring(l,k); + if ((l = sS.indexOf('(')) != -1) { + sS = sS.substring(0,l).replace(/^\s+/,'').replace(/\s+$/,''); + if (eval("typeof " + sS + " == 'undefined'")) window.onmousemove = null; + else str = sS + '(e);'; + } + } + if (!str) { + olCheckMouseCapture = false; + return; + } + } else { + if (fN[1]) str = fN[1]+'(e); '; + else { + l = f.indexOf('{')+1; + k = f.lastIndexOf('}'); + str = f.substring(l,k) + '\n'; + } + } + str += 'olMouseMove(e); '; + mseHandler = new Function('e', str); + } + + capExtent.onmousemove = mseHandler; + if (olNs4) capExtent.captureEvents(Event.MOUSEMOVE); +} + +//////// +// PARSING FUNCTIONS +//////// + +// Does the actual command parsing. +function parseTokens(pf, ar) { + // What the next argument is expected to be. + var v, i, mode=-1, par = (pf != 'ol_'); + var fnMark = (par && !ar.length ? 1 : 0); + + for (i = 0; i < ar.length; i++) { + if (mode < 0) { + // Arg is maintext,unless its a number between pmStart and pmUpper + // then its a command. + if (typeof ar[i] == 'number' && ar[i] > pmStart && ar[i] < pmUpper) { + fnMark = (par ? 1 : 0); + i--; // backup one so that the next block can parse it + } else { + switch(pf) { + case 'ol_': + ol_text = ar[i].toString(); + break; + default: + o3_text=ar[i].toString(); + } + } + mode = 0; + } else { + // Note: NS4 doesn't like switch cases with vars. + if (ar[i] >= pmCount || ar[i]==DONOTHING) { continue; } + if (ar[i]==INARRAY) { fnMark = 0; eval(pf+'text=ol_texts['+ar[++i]+'].toString()'); continue; } + if (ar[i]==CAPARRAY) { eval(pf+'cap=ol_caps['+ar[++i]+'].toString()'); continue; } + if (ar[i]==STICKY) { if (pf!='ol_') eval(pf+'sticky=1'); continue; } + if (ar[i]==BACKGROUND) { eval(pf+'background="'+ar[++i]+'"'); continue; } + if (ar[i]==NOCLOSE) { if (pf!='ol_') opt_NOCLOSE(); continue; } + if (ar[i]==CAPTION) { eval(pf+"cap='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==CENTER || ar[i]==LEFT || ar[i]==RIGHT) { eval(pf+'hpos='+ar[i]); if(pf!='ol_') olHautoFlag=1; continue; } + if (ar[i]==OFFSETX) { eval(pf+'offsetx='+ar[++i]); continue; } + if (ar[i]==OFFSETY) { eval(pf+'offsety='+ar[++i]); continue; } + if (ar[i]==FGCOLOR) { eval(pf+'fgcolor="'+ar[++i]+'"'); continue; } + if (ar[i]==BGCOLOR) { eval(pf+'bgcolor="'+ar[++i]+'"'); continue; } + if (ar[i]==TEXTCOLOR) { eval(pf+'textcolor="'+ar[++i]+'"'); continue; } + if (ar[i]==CAPCOLOR) { eval(pf+'capcolor="'+ar[++i]+'"'); continue; } + if (ar[i]==CLOSECOLOR) { eval(pf+'closecolor="'+ar[++i]+'"'); continue; } + if (ar[i]==WIDTH) { eval(pf+'width='+ar[++i]); continue; } + if (ar[i]==BORDER) { eval(pf+'border='+ar[++i]); continue; } + if (ar[i]==CELLPAD) { i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad')); continue; } + if (ar[i]==STATUS) { eval(pf+"status='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==AUTOSTATUS) { eval(pf +'autostatus=('+pf+'autostatus == 1) ? 0 : 1'); continue; } + if (ar[i]==AUTOSTATUSCAP) { eval(pf +'autostatus=('+pf+'autostatus == 2) ? 0 : 2'); continue; } + if (ar[i]==HEIGHT) { eval(pf+'height='+pf+'aboveheight='+ar[++i]); continue; } // Same param again. + if (ar[i]==CLOSETEXT) { eval(pf+"close='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==SNAPX) { eval(pf+'snapx='+ar[++i]); continue; } + if (ar[i]==SNAPY) { eval(pf+'snapy='+ar[++i]); continue; } + if (ar[i]==FIXX) { eval(pf+'fixx='+ar[++i]); continue; } + if (ar[i]==FIXY) { eval(pf+'fixy='+ar[++i]); continue; } + if (ar[i]==RELX) { eval(pf+'relx='+ar[++i]); continue; } + if (ar[i]==RELY) { eval(pf+'rely='+ar[++i]); continue; } + if (ar[i]==FGBACKGROUND) { eval(pf+'fgbackground="'+ar[++i]+'"'); continue; } + if (ar[i]==BGBACKGROUND) { eval(pf+'bgbackground="'+ar[++i]+'"'); continue; } + if (ar[i]==PADX) { eval(pf+'padxl='+ar[++i]); eval(pf+'padxr='+ar[++i]); continue; } + if (ar[i]==PADY) { eval(pf+'padyt='+ar[++i]); eval(pf+'padyb='+ar[++i]); continue; } + if (ar[i]==FULLHTML) { if (pf!='ol_') eval(pf+'fullhtml=1'); continue; } + if (ar[i]==BELOW || ar[i]==ABOVE) { eval(pf+'vpos='+ar[i]); if (pf!='ol_') olVautoFlag=1; continue; } + if (ar[i]==CAPICON) { eval(pf+'capicon="'+ar[++i]+'"'); continue; } + if (ar[i]==TEXTFONT) { eval(pf+"textfont='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==CAPTIONFONT) { eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==CLOSEFONT) { eval(pf+"closefont='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==TEXTSIZE) { eval(pf+'textsize="'+ar[++i]+'"'); continue; } + if (ar[i]==CAPTIONSIZE) { eval(pf+'captionsize="'+ar[++i]+'"'); continue; } + if (ar[i]==CLOSESIZE) { eval(pf+'closesize="'+ar[++i]+'"'); continue; } + if (ar[i]==TIMEOUT) { eval(pf+'timeout='+ar[++i]); continue; } + if (ar[i]==FUNCTION) { if (pf=='ol_') { if (typeof ar[i+1]!='number') { v=ar[++i]; ol_function=(typeof v=='function' ? v : null); }} else {fnMark = 0; v = null; if (typeof ar[i+1]!='number') v = ar[++i]; opt_FUNCTION(v); } continue; } + if (ar[i]==DELAY) { eval(pf+'delay='+ar[++i]); continue; } + if (ar[i]==HAUTO) { eval(pf+'hauto=('+pf+'hauto == 0) ? 1 : 0'); continue; } + if (ar[i]==VAUTO) { eval(pf+'vauto=('+pf+'vauto == 0) ? 1 : 0'); continue; } + if (ar[i]==CLOSECLICK) { eval(pf +'closeclick=('+pf+'closeclick == 0) ? 1 : 0'); continue; } + if (ar[i]==WRAP) { eval(pf +'wrap=('+pf+'wrap == 0) ? 1 : 0'); continue; } + if (ar[i]==FOLLOWMOUSE) { eval(pf +'followmouse=('+pf+'followmouse == 1) ? 0 : 1'); continue; } + if (ar[i]==MOUSEOFF) { eval(pf +'mouseoff=('+pf+'mouseoff==0) ? 1 : 0'); v=ar[i+1]; if (pf != 'ol_' && eval(pf+'mouseoff') && typeof v == 'number' && (v < pmStart || v > pmUpper)) olHideDelay=ar[++i]; continue; } + if (ar[i]==CLOSETITLE) { eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'"); continue; } + if (ar[i]==CSSOFF||ar[i]==CSSCLASS) { eval(pf+'css='+ar[i]); continue; } + if (ar[i]==COMPATMODE) { eval(pf+'compatmode=('+pf+'compatmode==0) ? 1 : 0'); continue; } + if (ar[i]==FGCLASS) { eval(pf+'fgclass="'+ar[++i]+'"'); continue; } + if (ar[i]==BGCLASS) { eval(pf+'bgclass="'+ar[++i]+'"'); continue; } + if (ar[i]==TEXTFONTCLASS) { eval(pf+'textfontclass="'+ar[++i]+'"'); continue; } + if (ar[i]==CAPTIONFONTCLASS) { eval(pf+'captionfontclass="'+ar[++i]+'"'); continue; } + if (ar[i]==CLOSEFONTCLASS) { eval(pf+'closefontclass="'+ar[++i]+'"'); continue; } + i = parseCmdLine(pf, i, ar); + } + } + + if (fnMark && o3_function) o3_text = o3_function(); + + if ((pf == 'o3_') && o3_wrap) { + o3_width = 0; + + var tReg=/<.*\n*>/ig; + if (!tReg.test(o3_text)) o3_text = o3_text.replace(/[ ]+/g, ' '); + if (!tReg.test(o3_cap))o3_cap = o3_cap.replace(/[ ]+/g, ' '); + } + if ((pf == 'o3_') && o3_sticky) { + if (!o3_close && (o3_frame != ol_frame)) o3_close = ol_close; + if (o3_mouseoff && (o3_frame == ol_frame)) opt_NOCLOSE(' '); + } +} + + +//////// +// LAYER FUNCTIONS +//////// + +// Writes to a layer +function layerWrite(txt) { + txt += "\n"; + if (olNs4) { + var lyr = o3_frame.document.layers['overDiv'].document + lyr.write(txt) + lyr.close() + } else if (typeof over.innerHTML != 'undefined') { + if (olIe5 && isMac) over.innerHTML = ''; + over.innerHTML = txt; + } else { + range = o3_frame.document.createRange(); + range.setStartAfter(over); + domfrag = range.createContextualFragment(txt); + + while (over.hasChildNodes()) { + over.removeChild(over.lastChild); + } + + over.appendChild(domfrag); + } +} + +// Make an object visible +function showObject(obj) { + runHook("showObject", FBEFORE); + + var theObj=(olNs4 ? obj : obj.style); + theObj.visibility = 'visible'; + + runHook("showObject", FAFTER); +} + +// Hides an object +function hideObject(obj) { + runHook("hideObject", FBEFORE); + + var theObj=(olNs4 ? obj : obj.style); + if (olNs6 && olShowId>0) { clearTimeout(olShowId); olShowId=0; } + theObj.visibility = 'hidden'; + theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0); + + if (o3_timerid > 0) clearTimeout(o3_timerid); + if (o3_delayid > 0) clearTimeout(o3_delayid); + + o3_timerid = 0; + o3_delayid = 0; + self.status = ""; + + if (obj.onmouseout||obj.onmouseover) { + if (olNs4) obj.releaseEvents(Event.MOUSEOUT || Event.MOUSEOVER); + obj.onmouseout = obj.onmouseover = null; + } + + runHook("hideObject", FAFTER); +} + +// Move a layer +function repositionTo(obj, xL, yL) { + var theObj=(olNs4 ? obj : obj.style); + theObj.left = xL + (!olNs4 ? 'px' : 0); + theObj.top = yL + (!olNs4 ? 'px' : 0); +} + +// Check position of cursor relative to overDiv DIVision; mouseOut function +function cursorOff() { + var left = parseInt(over.style.left); + var top = parseInt(over.style.top); + var right = left + (over.offsetWidth >= parseInt(o3_width) ? over.offsetWidth : parseInt(o3_width)); + var bottom = top + (over.offsetHeight >= o3_aboveheight ? over.offsetHeight : o3_aboveheight); + + if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true; + + return false; +} + + +//////// +// COMMAND FUNCTIONS +//////// + +// Calls callme or the default function. +function opt_FUNCTION(callme) { + o3_text = (callme ? (typeof callme=='string' ? (/.+\(.*\)/.test(callme) ? eval(callme) : callme) : callme()) : (o3_function ? o3_function() : 'No Function')); + + return 0; +} + +// Handle hovering +function opt_NOCLOSE(unused) { + if (!unused) o3_close = ""; + + if (olNs4) { + over.captureEvents(Event.MOUSEOUT || Event.MOUSEOVER); + over.onmouseover = function () { if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid = 0; } } + over.onmouseout = function (e) { if (olHideDelay) hideDelay(olHideDelay); else cClick(e); } + } else { + over.onmouseover = function () {hoveringSwitch = true; if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid =0; } } + } + + return 0; +} + +// Function to scan command line arguments for multiples +function opt_MULTIPLEARGS(i, args, parameter) { + var k=i, re, pV, str=''; + + for(k=i; kpmStart) break; + str += args[k] + ','; + } + if (str) str = str.substring(0,--str.length); + + k--; // reduce by one so the for loop this is in works correctly + pV=(olNs4 && /cellpad/i.test(parameter)) ? str.split(',')[0] : str; + eval(parameter + '="' + pV + '"'); + + return k; +} + +// Remove   in texts when done. +function nbspCleanup() { + if (o3_wrap) { + o3_text = o3_text.replace(/\ /g, ' '); + o3_cap = o3_cap.replace(/\ /g, ' '); + } +} + +// Escape embedded single quotes in text strings +function escSglQuote(str) { + return str.toString().replace(/'/g,"\\'"); +} + +// Onload handler for window onload event +function OLonLoad_handler(e) { + var re = /\w+\(.*\)[;\s]+/g, olre = /overlib\(|nd\(|cClick\(/, fn, l, i; + + if(!olLoaded) olLoaded=1; + + // Remove it for Gecko based browsers + if(window.removeEventListener && e.eventPhase == 3) window.removeEventListener("load",OLonLoad_handler,false); + else if(window.detachEvent) { // and for IE and Opera 4.x but execute calls to overlib, nd, or cClick() + window.detachEvent("onload",OLonLoad_handler); + var fN = document.body.getAttribute('onload'); + if (fN) { + fN=fN.toString().match(re); + if (fN && fN.length) { + for (i=0; i' : '
') : ''; + else { + fontStr='o3_'+whichString+'font'; + fontColor='o3_'+((whichString=='caption')? 'cap' : whichString)+'color'; + return (hasDims&&!olNs4) ? (isClose ? '' : '
') : ''; + } +} + +// Quotes Multi word font names; needed for CSS Standards adherence in font-family +function quoteMultiNameFonts(theFont) { + var v, pM=theFont.split(','); + for (var i=0; i 0) clearTimeout(o3_timerid); + + o3_timerid=setTimeout("cClick()",(o3_timeout=time)); + } +} + +// Was originally in the placeLayer() routine; separated out for future ease +function horizontalPlacement(browserWidth, horizontalScrollAmount, widthFix) { + var placeX, iwidth=browserWidth, winoffset=horizontalScrollAmount; + var parsedWidth = parseInt(o3_width); + + if (o3_fixx > -1 || o3_relx != null) { + // Fixed position + placeX=(o3_relx != null ? ( o3_relx < 0 ? winoffset +o3_relx+ iwidth - parsedWidth - widthFix : winoffset+o3_relx) : o3_fixx); + } else { + // If HAUTO, decide what to use. + if (o3_hauto == 1) { + if ((o3_x - winoffset) > (iwidth / 2)) { + o3_hpos = LEFT; + } else { + o3_hpos = RIGHT; + } + } + + // From mouse + if (o3_hpos == CENTER) { // Center + placeX = o3_x+o3_offsetx-(parsedWidth/2); + + if (placeX < winoffset) placeX = winoffset; + } + + if (o3_hpos == RIGHT) { // Right + placeX = o3_x+o3_offsetx; + + if ((placeX+parsedWidth) > (winoffset+iwidth - widthFix)) { + placeX = iwidth+winoffset - parsedWidth - widthFix; + if (placeX < 0) placeX = 0; + } + } + if (o3_hpos == LEFT) { // Left + placeX = o3_x-o3_offsetx-parsedWidth; + if (placeX < winoffset) placeX = winoffset; + } + + // Snapping! + if (o3_snapx > 1) { + var snapping = placeX % o3_snapx; + + if (o3_hpos == LEFT) { + placeX = placeX - (o3_snapx+snapping); + } else { + // CENTER and RIGHT + placeX = placeX+(o3_snapx - snapping); + } + + if (placeX < winoffset) placeX = winoffset; + } + } + + return placeX; +} + +// was originally in the placeLayer() routine; separated out for future ease +function verticalPlacement(browserHeight,verticalScrollAmount) { + var placeY, iheight=browserHeight, scrolloffset=verticalScrollAmount; + var parsedHeight=(o3_aboveheight ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)); + + if (o3_fixy > -1 || o3_rely != null) { + // Fixed position + placeY=(o3_rely != null ? (o3_rely < 0 ? scrolloffset+o3_rely+iheight - parsedHeight : scrolloffset+o3_rely) : o3_fixy); + } else { + // If VAUTO, decide what to use. + if (o3_vauto == 1) { + if ((o3_y - scrolloffset) > (iheight / 2) && o3_vpos == BELOW && (o3_y + parsedHeight + o3_offsety - (scrolloffset + iheight) > 0)) { + o3_vpos = ABOVE; + } else if (o3_vpos == ABOVE && (o3_y - (parsedHeight + o3_offsety) - scrolloffset < 0)) { + o3_vpos = BELOW; + } + } + + // From mouse + if (o3_vpos == ABOVE) { + if (o3_aboveheight == 0) o3_aboveheight = parsedHeight; + + placeY = o3_y - (o3_aboveheight+o3_offsety); + if (placeY < scrolloffset) placeY = scrolloffset; + } else { + // BELOW + placeY = o3_y+o3_offsety; + } + + // Snapping! + if (o3_snapy > 1) { + var snapping = placeY % o3_snapy; + + if (o3_aboveheight > 0 && o3_vpos == ABOVE) { + placeY = placeY - (o3_snapy+snapping); + } else { + placeY = placeY+(o3_snapy - snapping); + } + + if (placeY < scrolloffset) placeY = scrolloffset; + } + } + + return placeY; +} + +// checks positioning flags +function checkPositionFlags() { + if (olHautoFlag) olHautoFlag = o3_hauto=0; + if (olVautoFlag) olVautoFlag = o3_vauto=0; + return true; +} + +// get Browser window width +function windowWidth() { + var w; + if (o3_frame.innerWidth) w=o3_frame.innerWidth; + else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) + w=eval('o3_frame.'+docRoot+'.clientWidth'); + return w; +} + +// create the div container for popup content if it doesn't exist +function createDivContainer(id,frm,zValue) { + id = (id || 'overDiv'), frm = (frm || o3_frame), zValue = (zValue || 1000); + var objRef, divContainer = layerReference(id); + + if (divContainer == null) { + if (olNs4) { + divContainer = frm.document.layers[id] = new Layer(window.innerWidth, frm); + objRef = divContainer; + } else { + var body = (olIe4 ? frm.document.all.tags('BODY')[0] : frm.document.getElementsByTagName("BODY")[0]); + if (olIe4&&!document.getElementById) { + body.insertAdjacentHTML("beforeEnd",'
'); + divContainer=layerReference(id); + } else { + divContainer = frm.document.createElement("DIV"); + divContainer.id = id; + body.appendChild(divContainer); + } + objRef = divContainer.style; + } + + objRef.position = 'absolute'; + objRef.visibility = 'hidden'; + objRef.zIndex = zValue; + if (olIe4&&!olOp) objRef.left = objRef.top = '0px'; + else objRef.left = objRef.top = -10000 + (!olNs4 ? 'px' : 0); + } + + return divContainer; +} + +// get reference to a layer with ID=id +function layerReference(id) { + return (olNs4 ? o3_frame.document.layers[id] : (document.all ? o3_frame.document.all[id] : o3_frame.document.getElementById(id))); +} +//////// +// UTILITY FUNCTIONS +//////// + +// Checks if something is a function. +function isFunction(fnRef) { + var rtn = true; + + if (typeof fnRef == 'object') { + for (var i = 0; i < fnRef.length; i++) { + if (typeof fnRef[i]=='function') continue; + rtn = false; + break; + } + } else if (typeof fnRef != 'function') { + rtn = false; + } + + return rtn; +} + +// Converts an array into an argument string for use in eval. +function argToString(array, strtInd, argName) { + var jS = strtInd, aS = '', ar = array; + argName=(argName ? argName : 'ar'); + + if (ar.length > jS) { + for (var k = jS; k < ar.length; k++) aS += argName+'['+k+'], '; + aS = aS.substring(0, aS.length-2); + } + + return aS; +} + +// Places a hook in the correct position in a hook point. +function reOrder(hookPt, fnRef, order) { + var newPt = new Array(), match, i, j; + + if (!order || typeof order == 'undefined' || typeof order == 'number') return hookPt; + + if (typeof order=='function') { + if (typeof fnRef=='object') { + newPt = newPt.concat(fnRef); + } else { + newPt[newPt.length++]=fnRef; + } + + for (i = 0; i < hookPt.length; i++) { + match = false; + if (typeof fnRef == 'function' && hookPt[i] == fnRef) { + continue; + } else { + for(j = 0; j < fnRef.length; j++) if (hookPt[i] == fnRef[j]) { + match = true; + break; + } + } + if (!match) newPt[newPt.length++] = hookPt[i]; + } + + newPt[newPt.length++] = order; + + } else if (typeof order == 'object') { + if (typeof fnRef == 'object') { + newPt = newPt.concat(fnRef); + } else { + newPt[newPt.length++] = fnRef; + } + + for (j = 0; j < hookPt.length; j++) { + match = false; + if (typeof fnRef == 'function' && hookPt[j] == fnRef) { + continue; + } else { + for (i = 0; i < fnRef.length; i++) if (hookPt[j] == fnRef[i]) { + match = true; + break; + } + } + if (!match) newPt[newPt.length++]=hookPt[j]; + } + + for (i = 0; i < newPt.length; i++) hookPt[i] = newPt[i]; + newPt.length = 0; + + for (j = 0; j < hookPt.length; j++) { + match = false; + for (i = 0; i < order.length; i++) { + if (hookPt[j] == order[i]) { + match = true; + break; + } + } + if (!match) newPt[newPt.length++] = hookPt[j]; + } + newPt = newPt.concat(order); + } + + hookPt = newPt; + + return hookPt; +} + +//////// +// PLUGIN ACTIVATION FUNCTIONS +//////// + +// Runs plugin functions to set runtime variables. +function setRunTimeVariables(){ + if (typeof runTime != 'undefined' && runTime.length) { + for (var k = 0; k < runTime.length; k++) { + runTime[k](); + } + } +} + +// Runs plugin functions to parse commands. +function parseCmdLine(pf, i, args) { + if (typeof cmdLine != 'undefined' && cmdLine.length) { + for (var k = 0; k < cmdLine.length; k++) { + var j = cmdLine[k](pf, i, args); + if (j >- 1) { + i = j; + break; + } + } + } + + return i; +} + +// Runs plugin functions to do things after parse. +function postParseChecks(pf,args){ + if (typeof postParse != 'undefined' && postParse.length) { + for (var k = 0; k < postParse.length; k++) { + if (postParse[k](pf,args)) continue; + return false; // end now since have an error + } + } + return true; +} + + +//////// +// PLUGIN REGISTRATION FUNCTIONS +//////// + +// Registers commands and creates constants. +function registerCommands(cmdStr) { + if (typeof cmdStr!='string') return; + + var pM = cmdStr.split(','); + pms = pms.concat(pM); + + for (var i = 0; i< pM.length; i++) { + eval(pM[i].toUpperCase()+'='+pmCount++); + } +} + +// Registers no-parameter commands +function registerNoParameterCommands(cmdStr) { + if (!cmdStr && typeof cmdStr != 'string') return; + pmt=(!pmt) ? cmdStr : pmt + ',' + cmdStr; +} + +// Register a function to hook at a certain point. +function registerHook(fnHookTo, fnRef, hookType, optPm) { + var hookPt, last = typeof optPm; + + if (fnHookTo == 'plgIn'||fnHookTo == 'postParse') return; + if (typeof hookPts[fnHookTo] == 'undefined') hookPts[fnHookTo] = new FunctionReference(); + + hookPt = hookPts[fnHookTo]; + + if (hookType != null) { + if (hookType == FREPLACE) { + hookPt.ovload = fnRef; // replace normal overlib routine + if (fnHookTo.indexOf('ol_content_') > -1) hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; + + } else if (hookType == FBEFORE || hookType == FAFTER) { + var hookPt=(hookType == 1 ? hookPt.before : hookPt.after); + + if (typeof fnRef == 'object') { + hookPt = hookPt.concat(fnRef); + } else { + hookPt[hookPt.length++] = fnRef; + } + + if (optPm) hookPt = reOrder(hookPt, fnRef, optPm); + + } else if (hookType == FALTERNATE) { + if (last=='number') hookPt.alt[pms[optPm-1-pmStart]] = fnRef; + } else if (hookType == FCHAIN) { + hookPt = hookPt.chain; + if (typeof fnRef=='object') hookPt=hookPt.concat(fnRef); // add other functions + else hookPt[hookPt.length++]=fnRef; + } + + return; + } +} + +// Register a function that will set runtime variables. +function registerRunTimeFunction(fn) { + if (isFunction(fn)) { + if (typeof fn == 'object') { + runTime = runTime.concat(fn); + } else { + runTime[runTime.length++] = fn; + } + } +} + +// Register a function that will handle command parsing. +function registerCmdLineFunction(fn){ + if (isFunction(fn)) { + if (typeof fn == 'object') { + cmdLine = cmdLine.concat(fn); + } else { + cmdLine[cmdLine.length++] = fn; + } + } +} + +// Register a function that does things after command parsing. +function registerPostParseFunction(fn){ + if (isFunction(fn)) { + if (typeof fn == 'object') { + postParse = postParse.concat(fn); + } else { + postParse[postParse.length++] = fn; + } + } +} + +//////// +// PLUGIN REGISTRATION FUNCTIONS +//////// + +// Runs any hooks registered. +function runHook(fnHookTo, hookType) { + var l = hookPts[fnHookTo], k, rtnVal = null, optPm, arS, ar = runHook.arguments; + + if (hookType == FREPLACE) { + arS = argToString(ar, 2); + + if (typeof l == 'undefined' || !(l = l.ovload)) rtnVal = eval(fnHookTo+'('+arS+')'); + else rtnVal = eval('l('+arS+')'); + + } else if (hookType == FBEFORE || hookType == FAFTER) { + if (typeof l != 'undefined') { + l=(hookType == 1 ? l.before : l.after); + + if (l.length) { + arS = argToString(ar, 2); + for (var k = 0; k < l.length; k++) eval('l[k]('+arS+')'); + } + } + } else if (hookType == FALTERNATE) { + optPm = ar[2]; + arS = argToString(ar, 3); + + if (typeof l == 'undefined' || (l = l.alt[pms[optPm-1-pmStart]]) == 'undefined') { + rtnVal = eval(fnHookTo+'('+arS+')'); + } else { + rtnVal = eval('l('+arS+')'); + } + } else if (hookType == FCHAIN) { + arS=argToString(ar,2); + l=l.chain; + + for (k=l.length; k > 0; k--) if((rtnVal=eval('l[k-1]('+arS+')'))!=void(0)) break; + } + + return rtnVal; +} + +//////// +// OBJECT CONSTRUCTORS +//////// + +// Object for handling hooks. +function FunctionReference() { + this.ovload = null; + this.before = new Array(); + this.after = new Array(); + this.alt = new Array(); + this.chain = new Array(); +} + +// Object for simple access to the overLIB version used. +// Examples: simpleversion:351 major:3 minor:5 revision:1 +function Info(version, prerelease) { + this.version = version; + this.prerelease = prerelease; + + this.simpleversion = Math.round(this.version*100); + this.major = parseInt(this.simpleversion / 100); + this.minor = parseInt(this.simpleversion / 10) - this.major * 10; + this.revision = parseInt(this.simpleversion) - this.major * 100 - this.minor * 10; + this.meets = meets; +} + +// checks for Core Version required +function meets(reqdVersion) { + return (!reqdVersion) ? false : this.simpleversion >= Math.round(100*parseFloat(reqdVersion)); +} + + +//////// +// STANDARD REGISTRATIONS +//////// +registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSOFF); +registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSOFF); +registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSOFF); +registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSCLASS); +registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSCLASS); +registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSCLASS); +registerPostParseFunction(checkPositionFlags); +registerHook("hideObject", nbspCleanup, FAFTER); +registerHook("horizontalPlacement", horizontalPlacement, FCHAIN); +registerHook("verticalPlacement", verticalPlacement, FCHAIN); +if (olNs4||(olIe5&&isMac)||olKq) olLoaded=1; +registerNoParameterCommands('sticky,autostatus,autostatuscap,fullhtml,hauto,vauto,closeclick,wrap,followmouse,mouseoff,compatmode'); +/////// +// ESTABLISH MOUSECAPTURING +/////// + +// Capture events, alt. diffuses the overlib function. +var olCheckMouseCapture=true; +if ((olNs4 || olNs6 || olIe4)) { + olMouseCapture(); +} else { + overlib = no_overlib; + nd = no_overlib; + ver3fix = true; +} diff --git a/web/public_php/admin/overlib/overlib_anchor.js b/web/public_php/admin/overlib/overlib_anchor.js index c97b58c78..2dd75cf90 100644 --- a/web/public_php/admin/overlib/overlib_anchor.js +++ b/web/public_php/admin/overlib/overlib_anchor.js @@ -1,333 +1,333 @@ -//\///// -//\ overLIB Anchor Plugin -//\ This file requires overLIB 4.10 or later. -//\ -//\ overLIB 4.10 - You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2004. All rights reserved. -//\ Contributors are listed on the homepage. -//\ See http://www.bosrup.com/web/overlib/ for details. -// $Revision: 1.1 $ $Date: 2006/05/29 16:38:21 $ -//\///// -//\mini - - -//////// -// PRE-INIT -// Ignore these lines, configuration is below. -//////// -if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Anchor Plugin.'); -else { -registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign'); - - - -//////// -// DEFAULT CONFIGURATION -// Settings you want everywhere are set here. All of this can also be -// changed on your html page or through an overLIB call. -//////// -if (typeof ol_anchor == 'undefined') var ol_anchor = ''; -if (typeof ol_anchorx == 'undefined') var ol_anchorx = 0; -if (typeof ol_anchory == 'undefined') var ol_anchory = 0; -if (typeof ol_noanchorwarn == 'undefined') var ol_noanchorwarn = 1; -if (typeof ol_anchoralign == 'undefined') var ol_anchoralign = 'UL'; - -//////// -// END OF CONFIGURATION -// Don't change anything below this line, all configuration is above. -//////// - - - - - -//////// -// INIT -//////// -// Runtime variables init. Don't change for config! -var o3_anchor = ""; -var o3_anchorx = 0; -var o3_anchory = 0; -var o3_noanchorwarn = 1; -var o3_anchoralign = 'UL'; -var mrkObj, rmrkPosition; //reference mark object, reference mark position, an array; - - -//////// -// PLUGIN FUNCTIONS -//////// -function setAnchorVariables() { - o3_anchor = ol_anchor; - o3_anchorx = ol_anchorx; - o3_anchory = ol_anchory; - o3_noanchorwarn = ol_noanchorwarn; - o3_anchoralign = ol_anchoralign; - mrkObj = null; // initialize this variable -} - -// Parses Reference Mark commands -function parseAnchorExtras(pf,i,ar) { - var v, k=i; - - if (k < ar.length) { - if (ar[k] == ANCHOR) { eval(pf + "anchor = '" + escSglQuote(ar[++k]) + "'"); return k; } - if (ar[k] == ANCHORX) { eval(pf + 'anchorx = ' + ar[++k]); return k; } - if (ar[k] == ANCHORY) { eval(pf + 'anchory = ' + ar[++k]); return k; } - if (ar[k] == NOANCHORWARN) { eval(pf + 'noanchorwarn = (' + pf + 'noanchorwarn==1) ? 0 : 1'); return k; } - if (ar[k] == ANCHORALIGN) { k = opt_MULTIPLEARGS(++k, ar, (pf + 'anchoralign')); return k; } - } - - return -1; -} - - -/////// -// FUNCTION WHICH CHECKS FOR THE EXISTENCE OF A REFERENCE MARKER -/////// -function checkAnchorObject() { - var w = o3_anchor; - - if (w) { - if (!(mrkObj = getAnchorObjectRef(w))) { - if (o3_noanchorwarn) { - alert('WARNING! Reference mark "' + w + '" not found.'); - return false; - } else w = ''; - } - } - - return true; -} - -/////// -// EXTERNAL SUPPORT FUNCTIONS TO HANDLE ANCHOR PROPERTIES -/////// - -// Horizontal placement routine with anchors -function anchorHorizontal(browserWidth, horizontalScrollAmount, widthFix) { - var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor); - if (!hasAnchor) return void(0); - - // set o3_relx for follow scroll if defined - if (typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_relx = rmrkPosition[0]; - - return rmrkPosition[0]; -} - -// Vertical placement routine with anchors -function anchorVertical(browserHeight,verticalScrollAmount) { - var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor); - if (!hasAnchor) return void(0); - - // set o3_rely for follow scroll if defined - if (typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_rely = rmrkPosition[1]; - - return rmrkPosition[1]; -} - -// Stub function for the runHook routine -function anchorPreface() { - if (!mrkObj) return; - rmrkPosition = getAnchorLocation(mrkObj); -} - -// Get Reference Mark object -function getAnchorObjectRef(aObj) { - return getRefById(aObj, o3_frame.document) || getRefByName(aObj, o3_frame.document) -} - -// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com -function getAnchorLocation(objRef){ - var mkObj, of, offsets, mlyr - - mkObj = mlyr = objRef - offsets = [o3_anchorx, o3_anchory] - - if (document.layers){ - if (typeof mlyr.length != 'undefined' && mlyr.length > 1) { - mkObj = mlyr[0] - offsets[0] += mlyr[0].x + mlyr[1].pageX - offsets[1] += mlyr[0].y + mlyr[1].pageY - } else { - if(mlyr.toString().indexOf('Image') != -1 || mlyr.toString().indexOf('Anchor') != -1){ - offsets[0] += mlyr.x - offsets[1] += mlyr.y - } else { - offsets[0] += mlyr.pageX - offsets[1] += mlyr.pageY - } - } - } else { - offsets[0] += pageLocation(mlyr, 'Left') - offsets[1] += pageLocation(mlyr, 'Top') - } - - of = getAnchorOffsets(mkObj) - - if (typeof o3_dragimg != 'undefined' && o3_dragimg) { - olImgLeft = offsets[0]; - olImgTop = offsets[1]; - } - - offsets[0] += of[0] - offsets[1] += of[1] - - if (typeof o3_dragimg != 'undefined' && o3_dragimg) { - olImgRight = offsets[0]; - olImgBottom = offsets[1]; - return; - } - - return offsets; -} - -// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com -function getAnchorOffsets(mkObj){ - var fx = fy = 0, mp, puc, mkAry, sx = sy = 0, w = o3_anchoralign - var mW = mH = pW = pH = 0 - var off = [0, 0] - - mkAry = w.split(','); - - if (mkAry.length < 3) { - mp = mkAry[0].toUpperCase(); - puc = (mkAry.length == 1) ? mp : mkAry[1].toUpperCase(); - } else if (mkAry.length == 3) { - if (!isNaN(mkAry[0])) { - mp = mkAry.slice(0, 2); - puc = mkAry[2].toUpperCase(); - } else { - mp = mkAry[0].toUpperCase(); - puc = mkAry.slice(1); - } - } else { - mp = mkAry.slice(0, 2); - puc = mkAry.slice(2); - } - - var shdwPresent = typeof o3_shadow != 'undefined' && o3_shadow - - if (shdwPresent) { - sx = Math.abs(o3_shadowx); - sy = Math.abs(o3_shadowy); - } - - pW = (shdwPresent ? parseInt(o3_width) : (olNs4 ? over.clip.width : over.offsetWidth)) - pH = (shdwPresent ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)) - - if (olOp && o3_wrap) { - pW = (shdwPresent ? parseInt(o3_width) : (olNs4 ? over.clip.width : over.offsetWidth)) - pH = (shdwPresent ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)) - } - - if (!olOp && mkObj.toString().indexOf('Image') != -1){ - mW = mkObj.width - mH = mkObj.height - } else if (!olOp && mkObj.toString().indexOf('Anchor') != -1) { // enforced only for NS4 - mp = 'UL' - } else { - mW = (olNs4) ? mkObj.clip.width : mkObj.offsetWidth - mH = (olNs4) ? mkObj.clip.height : mkObj.offsetHeight - } - - if (!isNaN(mp) || typeof mp == 'object') { - if (typeof mp == 'object') { - fx = parseFloat(mp[0]); - fy = parseFloat(mp[1]); - } else - fx = fy = parseFloat(mp); - off = [Math.round(fx*mW), Math.round(fy*mH)]; - } else { - if (mp == 'UR') off = [mW, 0] - else if (mp == 'LL') off = [0, mH] - else if (mp == 'LR') off = [mW, mH] - } - - if (typeof o3_dragimg != 'undefined' && o3_dragimg) return off; - else { - if (!isNaN(puc) || typeof puc == 'object' ) { - if (typeof puc == 'object') { - fx = parseFloat(puc[0]); - fy = parseFloat(puc[1]); - } else - fx = fy = parseFloat(puc); - off[0] -= Math.round(fx*(pW - sx)); - off[1] -= Math.round(fy*(pH - sy)); - } else { - if (puc == 'UR') { - off[0] -= (pW - sx); - off[1] -= sy - } else if (puc == 'LL') { - off[0] -= sx; - off[1] -= (pH - sy) - } else if (puc == 'LR') { - off[0] -= (pW-sx); - off[1] -= (pH - sy) - } - } - return off - } -} - -// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com -function pageLocation(o, t){ - var x = 0 - - while(o.offsetParent){ - x += o['offset' + t] - o = o.offsetParent - } - x += o['offset' + t] - - return x -} - -// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com -function getRefById(l, d){ - var r = "", j - - d = (d || document) - if (d.all) return d.all[l] - else if (d.getElementById) return d.getElementById(l) - else if (d.layers && d.layers.length > 0) { - if (d.layers[l]) return d.layers[l] - - for (j=0; j < d.layers.length; j++) { - r = getRefById(l, d.layers[j].document) - if(r) return r - } - } - - return false -} - -// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com -function getRefByName(l, d) { - var r = null, j - - d = (d || document) - - if (d.images[l]) return d.images[l] - else if (d.anchors[l]) return d.anchors[l]; - else if (d.layers && d.layers.length > 0) { - for (j=0; j < d.layers.length; j++) { - r = getRefByName(l, d.layers[j].document) - if (r && r.length > 0) return r - else if (r) return [r, d.layers[j]] - } - } - - return null -} - -//////// -// PLUGIN REGISTRATIONS -//////// -registerRunTimeFunction(setAnchorVariables); -registerCmdLineFunction(parseAnchorExtras); -registerPostParseFunction(checkAnchorObject); -registerHook("createPopup", anchorPreface, FAFTER); -registerHook("horizontalPlacement", anchorHorizontal, FCHAIN); -registerHook("verticalPlacement", anchorVertical, FCHAIN); -if(olInfo.meets(4.10)) registerNoParameterCommands('noanchorwarn'); +//\///// +//\ overLIB Anchor Plugin +//\ This file requires overLIB 4.10 or later. +//\ +//\ overLIB 4.10 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +// $Revision: 1.1 $ $Date: 2006/05/29 16:38:21 $ +//\///// +//\mini + + +//////// +// PRE-INIT +// Ignore these lines, configuration is below. +//////// +if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Anchor Plugin.'); +else { +registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign'); + + + +//////// +// DEFAULT CONFIGURATION +// Settings you want everywhere are set here. All of this can also be +// changed on your html page or through an overLIB call. +//////// +if (typeof ol_anchor == 'undefined') var ol_anchor = ''; +if (typeof ol_anchorx == 'undefined') var ol_anchorx = 0; +if (typeof ol_anchory == 'undefined') var ol_anchory = 0; +if (typeof ol_noanchorwarn == 'undefined') var ol_noanchorwarn = 1; +if (typeof ol_anchoralign == 'undefined') var ol_anchoralign = 'UL'; + +//////// +// END OF CONFIGURATION +// Don't change anything below this line, all configuration is above. +//////// + + + + + +//////// +// INIT +//////// +// Runtime variables init. Don't change for config! +var o3_anchor = ""; +var o3_anchorx = 0; +var o3_anchory = 0; +var o3_noanchorwarn = 1; +var o3_anchoralign = 'UL'; +var mrkObj, rmrkPosition; //reference mark object, reference mark position, an array; + + +//////// +// PLUGIN FUNCTIONS +//////// +function setAnchorVariables() { + o3_anchor = ol_anchor; + o3_anchorx = ol_anchorx; + o3_anchory = ol_anchory; + o3_noanchorwarn = ol_noanchorwarn; + o3_anchoralign = ol_anchoralign; + mrkObj = null; // initialize this variable +} + +// Parses Reference Mark commands +function parseAnchorExtras(pf,i,ar) { + var v, k=i; + + if (k < ar.length) { + if (ar[k] == ANCHOR) { eval(pf + "anchor = '" + escSglQuote(ar[++k]) + "'"); return k; } + if (ar[k] == ANCHORX) { eval(pf + 'anchorx = ' + ar[++k]); return k; } + if (ar[k] == ANCHORY) { eval(pf + 'anchory = ' + ar[++k]); return k; } + if (ar[k] == NOANCHORWARN) { eval(pf + 'noanchorwarn = (' + pf + 'noanchorwarn==1) ? 0 : 1'); return k; } + if (ar[k] == ANCHORALIGN) { k = opt_MULTIPLEARGS(++k, ar, (pf + 'anchoralign')); return k; } + } + + return -1; +} + + +/////// +// FUNCTION WHICH CHECKS FOR THE EXISTENCE OF A REFERENCE MARKER +/////// +function checkAnchorObject() { + var w = o3_anchor; + + if (w) { + if (!(mrkObj = getAnchorObjectRef(w))) { + if (o3_noanchorwarn) { + alert('WARNING! Reference mark "' + w + '" not found.'); + return false; + } else w = ''; + } + } + + return true; +} + +/////// +// EXTERNAL SUPPORT FUNCTIONS TO HANDLE ANCHOR PROPERTIES +/////// + +// Horizontal placement routine with anchors +function anchorHorizontal(browserWidth, horizontalScrollAmount, widthFix) { + var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor); + if (!hasAnchor) return void(0); + + // set o3_relx for follow scroll if defined + if (typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_relx = rmrkPosition[0]; + + return rmrkPosition[0]; +} + +// Vertical placement routine with anchors +function anchorVertical(browserHeight,verticalScrollAmount) { + var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor); + if (!hasAnchor) return void(0); + + // set o3_rely for follow scroll if defined + if (typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_rely = rmrkPosition[1]; + + return rmrkPosition[1]; +} + +// Stub function for the runHook routine +function anchorPreface() { + if (!mrkObj) return; + rmrkPosition = getAnchorLocation(mrkObj); +} + +// Get Reference Mark object +function getAnchorObjectRef(aObj) { + return getRefById(aObj, o3_frame.document) || getRefByName(aObj, o3_frame.document) +} + +// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com +function getAnchorLocation(objRef){ + var mkObj, of, offsets, mlyr + + mkObj = mlyr = objRef + offsets = [o3_anchorx, o3_anchory] + + if (document.layers){ + if (typeof mlyr.length != 'undefined' && mlyr.length > 1) { + mkObj = mlyr[0] + offsets[0] += mlyr[0].x + mlyr[1].pageX + offsets[1] += mlyr[0].y + mlyr[1].pageY + } else { + if(mlyr.toString().indexOf('Image') != -1 || mlyr.toString().indexOf('Anchor') != -1){ + offsets[0] += mlyr.x + offsets[1] += mlyr.y + } else { + offsets[0] += mlyr.pageX + offsets[1] += mlyr.pageY + } + } + } else { + offsets[0] += pageLocation(mlyr, 'Left') + offsets[1] += pageLocation(mlyr, 'Top') + } + + of = getAnchorOffsets(mkObj) + + if (typeof o3_dragimg != 'undefined' && o3_dragimg) { + olImgLeft = offsets[0]; + olImgTop = offsets[1]; + } + + offsets[0] += of[0] + offsets[1] += of[1] + + if (typeof o3_dragimg != 'undefined' && o3_dragimg) { + olImgRight = offsets[0]; + olImgBottom = offsets[1]; + return; + } + + return offsets; +} + +// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com +function getAnchorOffsets(mkObj){ + var fx = fy = 0, mp, puc, mkAry, sx = sy = 0, w = o3_anchoralign + var mW = mH = pW = pH = 0 + var off = [0, 0] + + mkAry = w.split(','); + + if (mkAry.length < 3) { + mp = mkAry[0].toUpperCase(); + puc = (mkAry.length == 1) ? mp : mkAry[1].toUpperCase(); + } else if (mkAry.length == 3) { + if (!isNaN(mkAry[0])) { + mp = mkAry.slice(0, 2); + puc = mkAry[2].toUpperCase(); + } else { + mp = mkAry[0].toUpperCase(); + puc = mkAry.slice(1); + } + } else { + mp = mkAry.slice(0, 2); + puc = mkAry.slice(2); + } + + var shdwPresent = typeof o3_shadow != 'undefined' && o3_shadow + + if (shdwPresent) { + sx = Math.abs(o3_shadowx); + sy = Math.abs(o3_shadowy); + } + + pW = (shdwPresent ? parseInt(o3_width) : (olNs4 ? over.clip.width : over.offsetWidth)) + pH = (shdwPresent ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)) + + if (olOp && o3_wrap) { + pW = (shdwPresent ? parseInt(o3_width) : (olNs4 ? over.clip.width : over.offsetWidth)) + pH = (shdwPresent ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight)) + } + + if (!olOp && mkObj.toString().indexOf('Image') != -1){ + mW = mkObj.width + mH = mkObj.height + } else if (!olOp && mkObj.toString().indexOf('Anchor') != -1) { // enforced only for NS4 + mp = 'UL' + } else { + mW = (olNs4) ? mkObj.clip.width : mkObj.offsetWidth + mH = (olNs4) ? mkObj.clip.height : mkObj.offsetHeight + } + + if (!isNaN(mp) || typeof mp == 'object') { + if (typeof mp == 'object') { + fx = parseFloat(mp[0]); + fy = parseFloat(mp[1]); + } else + fx = fy = parseFloat(mp); + off = [Math.round(fx*mW), Math.round(fy*mH)]; + } else { + if (mp == 'UR') off = [mW, 0] + else if (mp == 'LL') off = [0, mH] + else if (mp == 'LR') off = [mW, mH] + } + + if (typeof o3_dragimg != 'undefined' && o3_dragimg) return off; + else { + if (!isNaN(puc) || typeof puc == 'object' ) { + if (typeof puc == 'object') { + fx = parseFloat(puc[0]); + fy = parseFloat(puc[1]); + } else + fx = fy = parseFloat(puc); + off[0] -= Math.round(fx*(pW - sx)); + off[1] -= Math.round(fy*(pH - sy)); + } else { + if (puc == 'UR') { + off[0] -= (pW - sx); + off[1] -= sy + } else if (puc == 'LL') { + off[0] -= sx; + off[1] -= (pH - sy) + } else if (puc == 'LR') { + off[0] -= (pW-sx); + off[1] -= (pH - sy) + } + } + return off + } +} + +// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com +function pageLocation(o, t){ + var x = 0 + + while(o.offsetParent){ + x += o['offset' + t] + o = o.offsetParent + } + x += o['offset' + t] + + return x +} + +// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com +function getRefById(l, d){ + var r = "", j + + d = (d || document) + if (d.all) return d.all[l] + else if (d.getElementById) return d.getElementById(l) + else if (d.layers && d.layers.length > 0) { + if (d.layers[l]) return d.layers[l] + + for (j=0; j < d.layers.length; j++) { + r = getRefById(l, d.layers[j].document) + if(r) return r + } + } + + return false +} + +// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com +function getRefByName(l, d) { + var r = null, j + + d = (d || document) + + if (d.images[l]) return d.images[l] + else if (d.anchors[l]) return d.anchors[l]; + else if (d.layers && d.layers.length > 0) { + for (j=0; j < d.layers.length; j++) { + r = getRefByName(l, d.layers[j].document) + if (r && r.length > 0) return r + else if (r) return [r, d.layers[j]] + } + } + + return null +} + +//////// +// PLUGIN REGISTRATIONS +//////// +registerRunTimeFunction(setAnchorVariables); +registerCmdLineFunction(parseAnchorExtras); +registerPostParseFunction(checkAnchorObject); +registerHook("createPopup", anchorPreface, FAFTER); +registerHook("horizontalPlacement", anchorHorizontal, FCHAIN); +registerHook("verticalPlacement", anchorVertical, FCHAIN); +if(olInfo.meets(4.10)) registerNoParameterCommands('noanchorwarn'); } \ No newline at end of file diff --git a/web/public_php/admin/overlib/overlib_anchor_mini.js b/web/public_php/admin/overlib/overlib_anchor_mini.js index c12a034df..e1e952e41 100644 --- a/web/public_php/admin/overlib/overlib_anchor_mini.js +++ b/web/public_php/admin/overlib/overlib_anchor_mini.js @@ -1,98 +1,98 @@ -//\///// -//\ overLIB Anchor Plugin -//\ This file requires overLIB 4.10 or later. -//\ -//\ overLIB 4.10 - You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2004. All rights reserved. -//\ Contributors are listed on the homepage. -//\ See http://www.bosrup.com/web/overlib/ for details. -//\///// -//\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL! -if(typeof olInfo=='undefined'||typeof olInfo.meets=='undefined'||!olInfo.meets(4.10))alert('overLIB 4.10 or later is required for the Anchor Plugin.');else{registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign'); -if(typeof ol_anchor=='undefined')var ol_anchor='';if(typeof ol_anchorx=='undefined')var ol_anchorx=0;if(typeof ol_anchory=='undefined')var ol_anchory=0;if(typeof ol_noanchorwarn=='undefined')var ol_noanchorwarn=1;if(typeof ol_anchoralign=='undefined')var ol_anchoralign='UL'; -var o3_anchor="",o3_anchorx=0,o3_anchory=0,o3_noanchorwarn=1,o3_anchoralign='UL',mrkObj,rmrkPosition; -function setAnchorVariables(){o3_anchor=ol_anchor;o3_anchorx=ol_anchorx;o3_anchory=ol_anchory;o3_noanchorwarn=ol_noanchorwarn;o3_anchoralign=ol_anchoralign;mrkObj=null;} -function parseAnchorExtras(pf,i,ar){var v,k=i; -if(k1){mkObj=mlyr[0] -offsets[0]+=mlyr[0].x+mlyr[1].pageX -offsets[1]+=mlyr[0].y+mlyr[1].pageY -}else{if(mlyr.toString().indexOf('Image')!=-1||mlyr.toString().indexOf('Anchor')!=-1){offsets[0]+=mlyr.x -offsets[1]+=mlyr.y -}else{offsets[0]+=mlyr.pageX -offsets[1]+=mlyr.pageY}} -}else{offsets[0]+=pageLocation(mlyr,'Left') -offsets[1]+=pageLocation(mlyr,'Top')} -of=getAnchorOffsets(mkObj) -if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgLeft=offsets[0];olImgTop=offsets[1];} -offsets[0]+=of[0] -offsets[1]+=of[1] -if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgRight=offsets[0];olImgBottom=offsets[1];return;} -return offsets;} -function getAnchorOffsets(mkObj){var fx=fy=0, mp,puc,mkAry,sx=sy=0,w=o3_anchoralign -var mW=mH=pW=pH=0 -var off=[0,0] -mkAry=w.split(','); -if(mkAry.length<3){mp=mkAry[0].toUpperCase();puc=(mkAry.length==1)?mp:mkAry[1].toUpperCase();}else if(mkAry.length==3){if(!isNaN(mkAry[0])){mp=mkAry.slice(0,2);puc=mkAry[2].toUpperCase();}else{mp=mkAry[0].toUpperCase();puc=mkAry.slice(1);} -}else{mp=mkAry.slice(0,2);puc=mkAry.slice(2);} -var shdwPresent=typeof o3_shadow!='undefined'&& o3_shadow -if(shdwPresent){sx=Math.abs(o3_shadowx);sy=Math.abs(o3_shadowy);} -pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) -pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight)) -if(olOp&& o3_wrap){pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) -pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight))} -if(!olOp&& mkObj.toString().indexOf('Image')!=-1){mW=mkObj.width -mH=mkObj.height -}else if(!olOp&& mkObj.toString().indexOf('Anchor')!=-1){mp='UL' -}else{mW=(olNs4)?mkObj.clip.width:mkObj.offsetWidth -mH=(olNs4)?mkObj.clip.height:mkObj.offsetHeight} -if(!isNaN(mp)||typeof mp=='object'){if(typeof mp=='object'){fx=parseFloat(mp[0]);fy=parseFloat(mp[1]);}else -fx=fy=parseFloat(mp);off=[Math.round(fx*mW),Math.round(fy*mH)];}else{if(mp=='UR')off=[mW,0] -else if(mp=='LL')off=[0,mH] -else if(mp=='LR')off=[mW,mH]} -if(typeof o3_dragimg!='undefined'&& o3_dragimg)return off;else{if(!isNaN(puc)||typeof puc=='object' ){if(typeof puc=='object'){fx=parseFloat(puc[0]);fy=parseFloat(puc[1]);}else -fx=fy=parseFloat(puc);off[0]-=Math.round(fx*(pW-sx));off[1]-=Math.round(fy*(pH-sy));}else{if(puc=='UR'){off[0]-=(pW-sx);off[1]-=sy -}else if(puc=='LL'){off[0]-=sx;off[1]-=(pH-sy) -}else if(puc=='LR'){off[0]-=(pW-sx);off[1]-=(pH-sy)}} -return off}} -function pageLocation(o,t){var x=0 -while(o.offsetParent){x+=o['offset'+t] -o=o.offsetParent} -x+=o['offset'+t] -return x} -function getRefById(l,d){var r="",j -d=(d||document) -if(d.all)return d.all[l] -else if(d.getElementById)return d.getElementById(l) -else if(d.layers&& d.layers.length>0){if(d.layers[l])return d.layers[l] -for(j=0;j0){for(j=0;j0)return r -else if(r)return [r,d.layers[j]]}} -return null} -registerRunTimeFunction(setAnchorVariables);registerCmdLineFunction(parseAnchorExtras);registerPostParseFunction(checkAnchorObject);registerHook("createPopup",anchorPreface,FAFTER);registerHook("horizontalPlacement",anchorHorizontal,FCHAIN);registerHook("verticalPlacement",anchorVertical,FCHAIN);if(olInfo.meets(4.10))registerNoParameterCommands('noanchorwarn'); -} +//\///// +//\ overLIB Anchor Plugin +//\ This file requires overLIB 4.10 or later. +//\ +//\ overLIB 4.10 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// +//\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL! +if(typeof olInfo=='undefined'||typeof olInfo.meets=='undefined'||!olInfo.meets(4.10))alert('overLIB 4.10 or later is required for the Anchor Plugin.');else{registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign'); +if(typeof ol_anchor=='undefined')var ol_anchor='';if(typeof ol_anchorx=='undefined')var ol_anchorx=0;if(typeof ol_anchory=='undefined')var ol_anchory=0;if(typeof ol_noanchorwarn=='undefined')var ol_noanchorwarn=1;if(typeof ol_anchoralign=='undefined')var ol_anchoralign='UL'; +var o3_anchor="",o3_anchorx=0,o3_anchory=0,o3_noanchorwarn=1,o3_anchoralign='UL',mrkObj,rmrkPosition; +function setAnchorVariables(){o3_anchor=ol_anchor;o3_anchorx=ol_anchorx;o3_anchory=ol_anchory;o3_noanchorwarn=ol_noanchorwarn;o3_anchoralign=ol_anchoralign;mrkObj=null;} +function parseAnchorExtras(pf,i,ar){var v,k=i; +if(k1){mkObj=mlyr[0] +offsets[0]+=mlyr[0].x+mlyr[1].pageX +offsets[1]+=mlyr[0].y+mlyr[1].pageY +}else{if(mlyr.toString().indexOf('Image')!=-1||mlyr.toString().indexOf('Anchor')!=-1){offsets[0]+=mlyr.x +offsets[1]+=mlyr.y +}else{offsets[0]+=mlyr.pageX +offsets[1]+=mlyr.pageY}} +}else{offsets[0]+=pageLocation(mlyr,'Left') +offsets[1]+=pageLocation(mlyr,'Top')} +of=getAnchorOffsets(mkObj) +if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgLeft=offsets[0];olImgTop=offsets[1];} +offsets[0]+=of[0] +offsets[1]+=of[1] +if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgRight=offsets[0];olImgBottom=offsets[1];return;} +return offsets;} +function getAnchorOffsets(mkObj){var fx=fy=0, mp,puc,mkAry,sx=sy=0,w=o3_anchoralign +var mW=mH=pW=pH=0 +var off=[0,0] +mkAry=w.split(','); +if(mkAry.length<3){mp=mkAry[0].toUpperCase();puc=(mkAry.length==1)?mp:mkAry[1].toUpperCase();}else if(mkAry.length==3){if(!isNaN(mkAry[0])){mp=mkAry.slice(0,2);puc=mkAry[2].toUpperCase();}else{mp=mkAry[0].toUpperCase();puc=mkAry.slice(1);} +}else{mp=mkAry.slice(0,2);puc=mkAry.slice(2);} +var shdwPresent=typeof o3_shadow!='undefined'&& o3_shadow +if(shdwPresent){sx=Math.abs(o3_shadowx);sy=Math.abs(o3_shadowy);} +pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) +pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight)) +if(olOp&& o3_wrap){pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) +pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight))} +if(!olOp&& mkObj.toString().indexOf('Image')!=-1){mW=mkObj.width +mH=mkObj.height +}else if(!olOp&& mkObj.toString().indexOf('Anchor')!=-1){mp='UL' +}else{mW=(olNs4)?mkObj.clip.width:mkObj.offsetWidth +mH=(olNs4)?mkObj.clip.height:mkObj.offsetHeight} +if(!isNaN(mp)||typeof mp=='object'){if(typeof mp=='object'){fx=parseFloat(mp[0]);fy=parseFloat(mp[1]);}else +fx=fy=parseFloat(mp);off=[Math.round(fx*mW),Math.round(fy*mH)];}else{if(mp=='UR')off=[mW,0] +else if(mp=='LL')off=[0,mH] +else if(mp=='LR')off=[mW,mH]} +if(typeof o3_dragimg!='undefined'&& o3_dragimg)return off;else{if(!isNaN(puc)||typeof puc=='object' ){if(typeof puc=='object'){fx=parseFloat(puc[0]);fy=parseFloat(puc[1]);}else +fx=fy=parseFloat(puc);off[0]-=Math.round(fx*(pW-sx));off[1]-=Math.round(fy*(pH-sy));}else{if(puc=='UR'){off[0]-=(pW-sx);off[1]-=sy +}else if(puc=='LL'){off[0]-=sx;off[1]-=(pH-sy) +}else if(puc=='LR'){off[0]-=(pW-sx);off[1]-=(pH-sy)}} +return off}} +function pageLocation(o,t){var x=0 +while(o.offsetParent){x+=o['offset'+t] +o=o.offsetParent} +x+=o['offset'+t] +return x} +function getRefById(l,d){var r="",j +d=(d||document) +if(d.all)return d.all[l] +else if(d.getElementById)return d.getElementById(l) +else if(d.layers&& d.layers.length>0){if(d.layers[l])return d.layers[l] +for(j=0;j0){for(j=0;j0)return r +else if(r)return [r,d.layers[j]]}} +return null} +registerRunTimeFunction(setAnchorVariables);registerCmdLineFunction(parseAnchorExtras);registerPostParseFunction(checkAnchorObject);registerHook("createPopup",anchorPreface,FAFTER);registerHook("horizontalPlacement",anchorHorizontal,FCHAIN);registerHook("verticalPlacement",anchorVertical,FCHAIN);if(olInfo.meets(4.10))registerNoParameterCommands('noanchorwarn'); +} diff --git a/web/public_php/admin/overlib/overlib_draggable.js b/web/public_php/admin/overlib/overlib_draggable.js index d6797982c..ab06c992b 100644 --- a/web/public_php/admin/overlib/overlib_draggable.js +++ b/web/public_php/admin/overlib/overlib_draggable.js @@ -1,174 +1,174 @@ -//\///// -//\ overLIB Draggable Plugin -//\ -//\ You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2003. All rights reserved. -//\ Contributors are listed on the homepage. -//\ See http://www.bosrup.com/web/overlib/ for details. -//\///// -//////// -// PRE-INIT -// Ignore these lines, configuration is below. -//////// -if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.14)) alert('overLIB 4.14 or later is required for the Draggable Plugin.'); -else { -registerCommands('draggable,altcut,dragimg'); -//////// -// DEFAULT CONFIGURATION -// Settings you want everywhere are set here. All of this can also be -// changed on your html page or through an overLIB call. -//////// -if (typeof ol_draggable=='undefined') var ol_draggable=0; -if (typeof ol_altcut=='undefined') var ol_altcut=0; -if (typeof ol_dragimg=='undefined') var ol_dragimg=''; -//////// -// END OF CONFIGURATION -// Don't change anything below this line, all configuration is above. -//////// -//////// -// INIT -//////// -// Runtime variables init. Don't change for config! -var o3_draggable=0; -var o3_altcut=0; -var o3_dragimg=''; -var olImgLeft,olImgTop; -var olImgObj; -var olMseMv; // hold old mouseMove routine -//////// -// PLUGIN FUNCTIONS -//////// -function setDragVariables() { - o3_draggable=ol_draggable; - o3_altcut=ol_altcut; - o3_dragimg=ol_dragimg; - olImgObj=null; -} -// Parses Draggable commands -function parseDragExtras(pf,i,ar) { - var k=i; - if (k < ar.length) { - if (ar[k]==DRAGGABLE) { eval(pf+'draggable=('+pf+'draggable==0) ? 1 : 0'); return k; } - if (ar[k]==ALTCUT) { eval(pf+'altcut=('+pf+'altcut==0) ? 1 : 0'); return k; } - if (ar[k]==DRAGIMG) { eval(pf+'dragimg="'+ar[++k]+'"'); return k; } - } - return -1; -} -////// -// PRESHOW PROCESSING FOR DRAGGABLE POPUPS -////// -function startDrag() { - // Initiate dragging if in same frame and its a sticky - if (o3_draggable) { - if (o3_sticky&&(o3_frame==ol_frame)) initDrag(); - else o3_draggable=0; - } -} -////// -// POSTHIDE PROCESSING FOR DRAGGABLE POPUPS -////// -function stopDrag() { - if (o3_draggable) endDrag(); -} -////// -// DRAGGABLE FUNCTIONS -////// -function initDrag() { - olMseMv=capExtent.onmousemove; - if(olNs4) { - document.captureEvents(Event.MOUSEDOWN | Event.CLICK); - document.onmousedown=grabEl; - document.onclick=function(e) {return routeEvent(e);} - } else { - over.onmousedown=grabEl; - } - if (o3_dragimg) chkForImgSupport(o3_dragimg); - return true; -} -// Checks for image for dragging -function chkForImgSupport(dragImg) { - if (dragImg) { - if (typeof getAnchorObjRef!='undefined') olImgObj=getAnchorObjRef(dragImg); - if (olImgObj==null) o3_dragimg=''; - } -} -// Sets cursor symbol -function setCursor(on) { - if (olNs4) return; - over.style.cursor=(on ? 'move' : 'auto'); -} -// Checks cursor position relative to image -function chkCursorPosition(Obj,XPos,YPos) { - if (Obj) { - o3_anchorx=o3_anchory=0; - o3_anchoralign='UL'; - getAnchorLocation(Obj); - if (XPos < olImgLeft||XPos > (olImgLeft+Obj.width)||YPos < olImgTop||YPos > (olImgTop+Obj.height)) return false; - } - return true; -} -// Sets up mouse grab for moving -function grabEl(e) { - var e=(e) ? e : event; - var X,Y; - var cKy=(olNs4 ? e.modifiers & Event.ALT_MASK : (!olOp ? e.altKey : e.ctrlKey)); - if ((o3_altcut ? !cKy : cKy)) { - // get mouse's current x,y location - X=(e.pageX || eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft')); - Y=(e.pageY || eval('e.clientY+o3_frame.'+docRoot+'.scrollTop')); - if (chkCursorPosition(olImgObj,X,Y)) { - if (olNs4) document.captureEvents(Event.MOUSEUP); - capExtent.onmousemove=moveEl; - document.onmouseup=function() {setCursor(0); if (olIe4) over.onselectstart=null; capExtent.onmousemove=olMseMv;} - setCursor(1); - if (olIe4) over.onselectstart=function() {return false;} - if (olNs4) { - cX=X - cY=Y - } else { - // get offsets from upper left hand corner of popup to keep popup from jummping - // when first starting to drag - cX=X-(olNs4 ? over.left : parseInt(over.style.left)); - cY=Y-(olNs4 ? over.top : parseInt(over.style.top)); - } - return (olNs4 ? routeEvent(e) : false); - } - } else setCursor(0); -} -// Moves popup to follow mouse -function moveEl(e) { - var e=(e) ? e : event; - var dX,dY,X,Y; - // get new mouse location - X=(e.pageX || eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft')); - Y=(e.pageY || eval('e.clientY+o3_frame.'+docRoot+'.scrollTop')); - if (chkCursorPosition(olImgObj,X,Y)){ - if (olNs4) { - dX=X-cX; cX=X; - dY=Y-cY; cY=Y; - over.moveBy(dX,dY); - } else - repositionTo(over,X-cX,Y-cY); // move popup to that position - } -} -// Cleanup for Drag end -function endDrag(obj) { - if (olNs4) { - document.releaseEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK); - document.onmousedown=document.onclick=null; - } else { - if(!obj) obj=over; - obj.onmousedown=null; - } - document.onmouseup= null; -} -//////// -// PLUGIN REGISTRATIONS -//////// -registerRunTimeFunction(setDragVariables); -registerCmdLineFunction(parseDragExtras); -registerHook("disp",startDrag,FBEFORE); -registerHook("hideObject",stopDrag,FAFTER); -if (olInfo.meets(4.14)) registerNoParameterCommands('draggable,altcut'); -} -//end +//\///// +//\ overLIB Draggable Plugin +//\ +//\ You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2003. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// +//////// +// PRE-INIT +// Ignore these lines, configuration is below. +//////// +if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.14)) alert('overLIB 4.14 or later is required for the Draggable Plugin.'); +else { +registerCommands('draggable,altcut,dragimg'); +//////// +// DEFAULT CONFIGURATION +// Settings you want everywhere are set here. All of this can also be +// changed on your html page or through an overLIB call. +//////// +if (typeof ol_draggable=='undefined') var ol_draggable=0; +if (typeof ol_altcut=='undefined') var ol_altcut=0; +if (typeof ol_dragimg=='undefined') var ol_dragimg=''; +//////// +// END OF CONFIGURATION +// Don't change anything below this line, all configuration is above. +//////// +//////// +// INIT +//////// +// Runtime variables init. Don't change for config! +var o3_draggable=0; +var o3_altcut=0; +var o3_dragimg=''; +var olImgLeft,olImgTop; +var olImgObj; +var olMseMv; // hold old mouseMove routine +//////// +// PLUGIN FUNCTIONS +//////// +function setDragVariables() { + o3_draggable=ol_draggable; + o3_altcut=ol_altcut; + o3_dragimg=ol_dragimg; + olImgObj=null; +} +// Parses Draggable commands +function parseDragExtras(pf,i,ar) { + var k=i; + if (k < ar.length) { + if (ar[k]==DRAGGABLE) { eval(pf+'draggable=('+pf+'draggable==0) ? 1 : 0'); return k; } + if (ar[k]==ALTCUT) { eval(pf+'altcut=('+pf+'altcut==0) ? 1 : 0'); return k; } + if (ar[k]==DRAGIMG) { eval(pf+'dragimg="'+ar[++k]+'"'); return k; } + } + return -1; +} +////// +// PRESHOW PROCESSING FOR DRAGGABLE POPUPS +////// +function startDrag() { + // Initiate dragging if in same frame and its a sticky + if (o3_draggable) { + if (o3_sticky&&(o3_frame==ol_frame)) initDrag(); + else o3_draggable=0; + } +} +////// +// POSTHIDE PROCESSING FOR DRAGGABLE POPUPS +////// +function stopDrag() { + if (o3_draggable) endDrag(); +} +////// +// DRAGGABLE FUNCTIONS +////// +function initDrag() { + olMseMv=capExtent.onmousemove; + if(olNs4) { + document.captureEvents(Event.MOUSEDOWN | Event.CLICK); + document.onmousedown=grabEl; + document.onclick=function(e) {return routeEvent(e);} + } else { + over.onmousedown=grabEl; + } + if (o3_dragimg) chkForImgSupport(o3_dragimg); + return true; +} +// Checks for image for dragging +function chkForImgSupport(dragImg) { + if (dragImg) { + if (typeof getAnchorObjRef!='undefined') olImgObj=getAnchorObjRef(dragImg); + if (olImgObj==null) o3_dragimg=''; + } +} +// Sets cursor symbol +function setCursor(on) { + if (olNs4) return; + over.style.cursor=(on ? 'move' : 'auto'); +} +// Checks cursor position relative to image +function chkCursorPosition(Obj,XPos,YPos) { + if (Obj) { + o3_anchorx=o3_anchory=0; + o3_anchoralign='UL'; + getAnchorLocation(Obj); + if (XPos < olImgLeft||XPos > (olImgLeft+Obj.width)||YPos < olImgTop||YPos > (olImgTop+Obj.height)) return false; + } + return true; +} +// Sets up mouse grab for moving +function grabEl(e) { + var e=(e) ? e : event; + var X,Y; + var cKy=(olNs4 ? e.modifiers & Event.ALT_MASK : (!olOp ? e.altKey : e.ctrlKey)); + if ((o3_altcut ? !cKy : cKy)) { + // get mouse's current x,y location + X=(e.pageX || eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft')); + Y=(e.pageY || eval('e.clientY+o3_frame.'+docRoot+'.scrollTop')); + if (chkCursorPosition(olImgObj,X,Y)) { + if (olNs4) document.captureEvents(Event.MOUSEUP); + capExtent.onmousemove=moveEl; + document.onmouseup=function() {setCursor(0); if (olIe4) over.onselectstart=null; capExtent.onmousemove=olMseMv;} + setCursor(1); + if (olIe4) over.onselectstart=function() {return false;} + if (olNs4) { + cX=X + cY=Y + } else { + // get offsets from upper left hand corner of popup to keep popup from jummping + // when first starting to drag + cX=X-(olNs4 ? over.left : parseInt(over.style.left)); + cY=Y-(olNs4 ? over.top : parseInt(over.style.top)); + } + return (olNs4 ? routeEvent(e) : false); + } + } else setCursor(0); +} +// Moves popup to follow mouse +function moveEl(e) { + var e=(e) ? e : event; + var dX,dY,X,Y; + // get new mouse location + X=(e.pageX || eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft')); + Y=(e.pageY || eval('e.clientY+o3_frame.'+docRoot+'.scrollTop')); + if (chkCursorPosition(olImgObj,X,Y)){ + if (olNs4) { + dX=X-cX; cX=X; + dY=Y-cY; cY=Y; + over.moveBy(dX,dY); + } else + repositionTo(over,X-cX,Y-cY); // move popup to that position + } +} +// Cleanup for Drag end +function endDrag(obj) { + if (olNs4) { + document.releaseEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK); + document.onmousedown=document.onclick=null; + } else { + if(!obj) obj=over; + obj.onmousedown=null; + } + document.onmouseup= null; +} +//////// +// PLUGIN REGISTRATIONS +//////// +registerRunTimeFunction(setDragVariables); +registerCmdLineFunction(parseDragExtras); +registerHook("disp",startDrag,FBEFORE); +registerHook("hideObject",stopDrag,FAFTER); +if (olInfo.meets(4.14)) registerNoParameterCommands('draggable,altcut'); +} +//end diff --git a/web/public_php/admin/overlib/overlib_draggable_mini.js b/web/public_php/admin/overlib/overlib_draggable_mini.js index d956eda1c..59f8aafeb 100644 --- a/web/public_php/admin/overlib/overlib_draggable_mini.js +++ b/web/public_php/admin/overlib/overlib_draggable_mini.js @@ -1,11 +1,11 @@ -//\///// -//\ overLIB Draggable Plugin -//\ -//\ You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2003. All rights reserved. -//\ Contributors are listed on the homepage. -//\ See http://www.bosrup.com/web/overlib/ for details. -//\///// +//\///// +//\ overLIB Draggable Plugin +//\ +//\ You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2003. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// if(typeof olInfo=='undefined'||typeof olInfo.meets=='undefined'||!olInfo.meets(4.14))alert('overLIB 4.14 or later is required for the Draggable Plugin.');else{registerCommands('draggable,altcut,dragimg'); if(typeof ol_draggable=='undefined')var ol_draggable=0;if(typeof ol_altcut=='undefined')var ol_altcut=0;if(typeof ol_dragimg=='undefined')var ol_dragimg=''; var o3_draggable=0,o3_altcut=0,o3_dragimg='',olImgLeft,olImgTop,olImgObj,olMseMv; diff --git a/web/public_php/admin/overlib/overlib_mini.js b/web/public_php/admin/overlib/overlib_mini.js index a2df535b2..6262e3ee5 100644 --- a/web/public_php/admin/overlib/overlib_mini.js +++ b/web/public_php/admin/overlib/overlib_mini.js @@ -1,20 +1,20 @@ -//\///// -//\ overLIB 4.21 - You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2004. All rights reserved. -//\ -//\ Contributors are listed on the homepage. -//\ This file might be old, always check for the latest version at: -//\ http://www.bosrup.com/web/overlib/ -//\ -//\ Please read the license agreement (available through the link above) -//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. -//\ -//\ Do not sell this as your own work or remove this copyright notice. -//\ For full details on copying or changing this script please read the -//\ license agreement at the link above. Please give credit on sites that -//\ use overLIB and submit changes of the script so other people can use -//\ them as well. -//\///// +//\///// +//\ overLIB 4.21 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ +//\ Contributors are listed on the homepage. +//\ This file might be old, always check for the latest version at: +//\ http://www.bosrup.com/web/overlib/ +//\ +//\ Please read the license agreement (available through the link above) +//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. +//\ +//\ Do not sell this as your own work or remove this copyright notice. +//\ For full details on copying or changing this script please read the +//\ license agreement at the link above. Please give credit on sites that +//\ use overLIB and submit changes of the script so other people can use +//\ them as well. +//\///// //\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL! var olLoaded=0,pmStart=10000000,pmUpper=10001000,pmCount=pmStart+1,pmt='',pms=new Array(),olInfo=new Info('4.21',1),FREPLACE=0,FBEFORE=1,FAFTER=2,FALTERNATE=3,FCHAIN=4,olHideForm=0,olHautoFlag=0,olVautoFlag=0,hookPts=new Array(),postParse=new Array(),cmdLine=new Array(),runTime=new Array(); registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass'); diff --git a/web/public_php/ams/css/custom.css b/web/public_php/ams/css/custom.css index 7a36a6799..ec7b90139 100644 --- a/web/public_php/ams/css/custom.css +++ b/web/public_php/ams/css/custom.css @@ -1,139 +1,139 @@ -.box-content { - background: white; -} - -.box-header { - background-color: white; -} - -.top-block { - background-color: white; - border-radius: 5px; -} - -.row-fluid [class*="span"] { - min-height: 28px; -} - -.login-header -{ - height:190px; -} - -.brand img -{ - height:100%; - margin-bottom:-18px; - margin-top:-15px; - width:auto; -} - -#for-is-ajax -{ - display:none; -} - -.navbar { - border-bottom: 0px; -} - -.flags { - display: block; - position:relative; - left:290px; - top:28px; -} - -.flags_no_visible_elements{ - display: block; - position:relative; - left:67%; - top:210px; -} - -.input-prepend .add-on, -.input-append .add-on { - height: auto; -} - -select, -textarea, -input[type="text"], -input[type="password"], -input[type="datetime"], -input[type="datetime-local"], -input[type="date"], -input[type="month"], -input[type="time"], -input[type="week"], -input[type="number"], -input[type="email"], -input[type="url"], -input[type="search"], -input[type="tel"], -input[type="color"], -.uneditable-input { - height: auto; -} - -.btn .caret { - margin: 10px; -} - -.btn .caret { - border-top-color: #333; -} - -.table-bordered { - border-collapse: collapse; -} - -.table { -margin-top: 10px; -} - -.nav { - margin-bottom: 22px; -} - -.radio, .checkbox { - display: table-row-group; -} - -.gender-list { - margin-left: 22px; -} - -.lg-icon { - font-size: 20px; - margin: 5px; -} - -.sidebar-nav { - padding-top: 5px; -} - -.sidebar-nav .nav-header{ - color:#666; -} - -.flags_logged_in{ - display: inline; - position:absolute; - margin:7px; -} - -.setup-width { - width:75%; -} - -.js-masonry { - padding-left: -1; - padding-right: -1; - margin-left: -1; - margin-right: -1; -} - -.col-sm-4 { - width: 33.333%; +.box-content { + background: white; +} + +.box-header { + background-color: white; +} + +.top-block { + background-color: white; + border-radius: 5px; +} + +.row-fluid [class*="span"] { + min-height: 28px; +} + +.login-header +{ + height:190px; +} + +.brand img +{ + height:100%; + margin-bottom:-18px; + margin-top:-15px; + width:auto; +} + +#for-is-ajax +{ + display:none; +} + +.navbar { + border-bottom: 0px; +} + +.flags { + display: block; + position:relative; + left:290px; + top:28px; +} + +.flags_no_visible_elements{ + display: block; + position:relative; + left:67%; + top:210px; +} + +.input-prepend .add-on, +.input-append .add-on { + height: auto; +} + +select, +textarea, +input[type="text"], +input[type="password"], +input[type="datetime"], +input[type="datetime-local"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="week"], +input[type="number"], +input[type="email"], +input[type="url"], +input[type="search"], +input[type="tel"], +input[type="color"], +.uneditable-input { + height: auto; +} + +.btn .caret { + margin: 10px; +} + +.btn .caret { + border-top-color: #333; +} + +.table-bordered { + border-collapse: collapse; +} + +.table { +margin-top: 10px; +} + +.nav { + margin-bottom: 22px; +} + +.radio, .checkbox { + display: table-row-group; +} + +.gender-list { + margin-left: 22px; +} + +.lg-icon { + font-size: 20px; + margin: 5px; +} + +.sidebar-nav { + padding-top: 5px; +} + +.sidebar-nav .nav-header{ + color:#666; +} + +.flags_logged_in{ + display: inline; + position:absolute; + margin:7px; +} + +.setup-width { + width:75%; +} + +.js-masonry { + padding-left: -1; + padding-right: -1; + margin-left: -1; + margin-right: -1; +} + +.col-sm-4 { + width: 33.333%; } \ No newline at end of file diff --git a/web/public_php/ams/css/uploadify.css b/web/public_php/ams/css/uploadify.css index 1df3e3e9d..89e193260 100644 --- a/web/public_php/ams/css/uploadify.css +++ b/web/public_php/ams/css/uploadify.css @@ -1,92 +1,92 @@ -/* -Uploadify -Copyright (c) 2012 Reactive Apps, Ronnie Garcia -Released under the MIT License -*/ - -.uploadify { - position: relative; - margin-bottom: 1em; -} -.uploadify-button { - background-color: #505050; - background-image: linear-gradient(bottom, #505050 0%, #707070 100%); - background-image: -o-linear-gradient(bottom, #505050 0%, #707070 100%); - background-image: -moz-linear-gradient(bottom, #505050 0%, #707070 100%); - background-image: -webkit-linear-gradient(bottom, #505050 0%, #707070 100%); - background-image: -ms-linear-gradient(bottom, #505050 0%, #707070 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, #505050), - color-stop(1, #707070) - ); - background-position: center top; - background-repeat: no-repeat; - -webkit-border-radius: 30px; - -moz-border-radius: 30px; - border-radius: 30px; - border: 2px solid #808080; - color: #FFF; - font: bold 12px Arial, Helvetica, sans-serif; - text-align: center; - text-shadow: 0 -1px 0 rgba(0,0,0,0.25); - width: 100%; -} -.uploadify:hover .uploadify-button { - background-color: #606060; - background-image: linear-gradient(top, #606060 0%, #808080 100%); - background-image: -o-linear-gradient(top, #606060 0%, #808080 100%); - background-image: -moz-linear-gradient(top, #606060 0%, #808080 100%); - background-image: -webkit-linear-gradient(top, #606060 0%, #808080 100%); - background-image: -ms-linear-gradient(top, #606060 0%, #808080 100%); - background-image: -webkit-gradient( - linear, - left bottom, - left top, - color-stop(0, #606060), - color-stop(1, #808080) - ); - background-position: center bottom; -} -.uploadify-button.disabled { - background-color: #D0D0D0; - color: #808080; -} -.uploadify-queue { - margin-bottom: 1em; -} -.uploadify-queue-item { - background-color: #F5F5F5; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - font: 11px Verdana, Geneva, sans-serif; - margin-top: 5px; - max-width: 350px; - padding: 10px; -} -.uploadify-error { - background-color: #FDE5DD !important; -} -.uploadify-queue-item .cancel a { - background: url('../img/uploadify-cancel.png') 0 0 no-repeat; - float: right; - height: 16px; - text-indent: -9999px; - width: 16px; -} -.uploadify-queue-item.completed { - background-color: #E5E5E5; -} -.uploadify-progress { - background-color: #E5E5E5; - margin-top: 10px; - width: 100%; -} -.uploadify-progress-bar { - background-color: #0099FF; - height: 3px; - width: 1px; +/* +Uploadify +Copyright (c) 2012 Reactive Apps, Ronnie Garcia +Released under the MIT License +*/ + +.uploadify { + position: relative; + margin-bottom: 1em; +} +.uploadify-button { + background-color: #505050; + background-image: linear-gradient(bottom, #505050 0%, #707070 100%); + background-image: -o-linear-gradient(bottom, #505050 0%, #707070 100%); + background-image: -moz-linear-gradient(bottom, #505050 0%, #707070 100%); + background-image: -webkit-linear-gradient(bottom, #505050 0%, #707070 100%); + background-image: -ms-linear-gradient(bottom, #505050 0%, #707070 100%); + background-image: -webkit-gradient( + linear, + left bottom, + left top, + color-stop(0, #505050), + color-stop(1, #707070) + ); + background-position: center top; + background-repeat: no-repeat; + -webkit-border-radius: 30px; + -moz-border-radius: 30px; + border-radius: 30px; + border: 2px solid #808080; + color: #FFF; + font: bold 12px Arial, Helvetica, sans-serif; + text-align: center; + text-shadow: 0 -1px 0 rgba(0,0,0,0.25); + width: 100%; +} +.uploadify:hover .uploadify-button { + background-color: #606060; + background-image: linear-gradient(top, #606060 0%, #808080 100%); + background-image: -o-linear-gradient(top, #606060 0%, #808080 100%); + background-image: -moz-linear-gradient(top, #606060 0%, #808080 100%); + background-image: -webkit-linear-gradient(top, #606060 0%, #808080 100%); + background-image: -ms-linear-gradient(top, #606060 0%, #808080 100%); + background-image: -webkit-gradient( + linear, + left bottom, + left top, + color-stop(0, #606060), + color-stop(1, #808080) + ); + background-position: center bottom; +} +.uploadify-button.disabled { + background-color: #D0D0D0; + color: #808080; +} +.uploadify-queue { + margin-bottom: 1em; +} +.uploadify-queue-item { + background-color: #F5F5F5; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + font: 11px Verdana, Geneva, sans-serif; + margin-top: 5px; + max-width: 350px; + padding: 10px; +} +.uploadify-error { + background-color: #FDE5DD !important; +} +.uploadify-queue-item .cancel a { + background: url('../img/uploadify-cancel.png') 0 0 no-repeat; + float: right; + height: 16px; + text-indent: -9999px; + width: 16px; +} +.uploadify-queue-item.completed { + background-color: #E5E5E5; +} +.uploadify-progress { + background-color: #E5E5E5; + margin-top: 10px; + width: 100%; +} +.uploadify-progress-bar { + background-color: #0099FF; + height: 3px; + width: 1px; } \ No newline at end of file diff --git a/web/public_php/ams/js/jquery.uploadify-3.1.js b/web/public_php/ams/js/jquery.uploadify-3.1.js index 959068150..a4c6409e3 100644 --- a/web/public_php/ams/js/jquery.uploadify-3.1.js +++ b/web/public_php/ams/js/jquery.uploadify-3.1.js @@ -1,1971 +1,1971 @@ -/* -Uploadify v3.1.1 -Copyright (c) 2012 Reactive Apps, Ronnie Garcia -Released under the MIT License - -SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com -mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ -SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: -http://www.opensource.org/licenses/mit-license.php -SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: -http://www.opensource.org/licenses/mit-license.php - -SWFObject v2.2 -is released under the MIT License -*/ -; -var swfobject = function () { - var aq = "undefined", - aD = "object", - ab = "Shockwave Flash", - X = "ShockwaveFlash.ShockwaveFlash", - aE = "application/x-shockwave-flash", - ac = "SWFObjectExprInst", - ax = "onreadystatechange", - af = window, - aL = document, - aB = navigator, - aa = false, - Z = [aN], - aG = [], - ag = [], - al = [], - aJ, ad, ap, at, ak = false, - aU = false, - aH, an, aI = true, - ah = function () { - var a = typeof aL.getElementById != aq && typeof aL.getElementsByTagName != aq && typeof aL.createElement != aq, - e = aB.userAgent.toLowerCase(), - c = aB.platform.toLowerCase(), - h = c ? /win/.test(c) : /win/.test(e), - j = c ? /mac/.test(c) : /mac/.test(e), - g = /webkit/.test(e) ? parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, - d = !+"\v1", - f = [0, 0, 0], - k = null; - if (typeof aB.plugins != aq && typeof aB.plugins[ab] == aD) { - k = aB.plugins[ab].description; - if (k && !(typeof aB.mimeTypes != aq && aB.mimeTypes[aE] && !aB.mimeTypes[aE].enabledPlugin)) { - aa = true; - d = false; - k = k.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); - f[0] = parseInt(k.replace(/^(.*)\..*$/, "$1"), 10); - f[1] = parseInt(k.replace(/^.*\.(.*)\s.*$/, "$1"), 10); - f[2] = /[a-zA-Z]/.test(k) ? parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; - } - } else { - if (typeof af.ActiveXObject != aq) { - try { - var i = new ActiveXObject(X); - if (i) { - k = i.GetVariable("$version"); - if (k) { - d = true; - k = k.split(" ")[1].split(","); - f = [parseInt(k[0], 10), parseInt(k[1], 10), parseInt(k[2], 10)]; - } - } - } catch (b) {} - } - } - return { - w3: a, - pv: f, - wk: g, - ie: d, - win: h, - mac: j - }; - }(), - aK = function () { - if (!ah.w3) { - return; - } - if ((typeof aL.readyState != aq && aL.readyState == "complete") || (typeof aL.readyState == aq && (aL.getElementsByTagName("body")[0] || aL.body))) { - aP(); - } - if (!ak) { - if (typeof aL.addEventListener != aq) { - aL.addEventListener("DOMContentLoaded", aP, false); - } - if (ah.ie && ah.win) { - aL.attachEvent(ax, function () { - if (aL.readyState == "complete") { - aL.detachEvent(ax, arguments.callee); - aP(); - } - }); - if (af == top) { - (function () { - if (ak) { - return; - } - try { - aL.documentElement.doScroll("left"); - } catch (a) { - setTimeout(arguments.callee, 0); - return; - } - aP(); - })(); - } - } - if (ah.wk) { - (function () { - if (ak) { - return; - } - if (!/loaded|complete/.test(aL.readyState)) { - setTimeout(arguments.callee, 0); - return; - } - aP(); - })(); - } - aC(aP); - } - }(); - - function aP() { - if (ak) { - return; - } - try { - var b = aL.getElementsByTagName("body")[0].appendChild(ar("span")); - b.parentNode.removeChild(b); - } catch (a) { - return; - } - ak = true; - var d = Z.length; - for (var c = 0; c < d; c++) { - Z[c](); - } - } - function aj(a) { - if (ak) { - a(); - } else { - Z[Z.length] = a; - } - } - function aC(a) { - if (typeof af.addEventListener != aq) { - af.addEventListener("load", a, false); - } else { - if (typeof aL.addEventListener != aq) { - aL.addEventListener("load", a, false); - } else { - if (typeof af.attachEvent != aq) { - aM(af, "onload", a); - } else { - if (typeof af.onload == "function") { - var b = af.onload; - af.onload = function () { - b(); - a(); - }; - } else { - af.onload = a; - } - } - } - } - } - function aN() { - if (aa) { - Y(); - } else { - am(); - } - } - function Y() { - var d = aL.getElementsByTagName("body")[0]; - var b = ar(aD); - b.setAttribute("type", aE); - var a = d.appendChild(b); - if (a) { - var c = 0; - (function () { - if (typeof a.GetVariable != aq) { - var e = a.GetVariable("$version"); - if (e) { - e = e.split(" ")[1].split(","); - ah.pv = [parseInt(e[0], 10), parseInt(e[1], 10), parseInt(e[2], 10)]; - } - } else { - if (c < 10) { - c++; - setTimeout(arguments.callee, 10); - return; - } - } - d.removeChild(b); - a = null; - am(); - })(); - } else { - am(); - } - } - function am() { - var g = aG.length; - if (g > 0) { - for (var h = 0; h < g; h++) { - var c = aG[h].id; - var l = aG[h].callbackFn; - var a = { - success: false, - id: c - }; - if (ah.pv[0] > 0) { - var i = aS(c); - if (i) { - if (ao(aG[h].swfVersion) && !(ah.wk && ah.wk < 312)) { - ay(c, true); - if (l) { - a.success = true; - a.ref = av(c); - l(a); - } - } else { - if (aG[h].expressInstall && au()) { - var e = {}; - e.data = aG[h].expressInstall; - e.width = i.getAttribute("width") || "0"; - e.height = i.getAttribute("height") || "0"; - if (i.getAttribute("class")) { - e.styleclass = i.getAttribute("class"); - } - if (i.getAttribute("align")) { - e.align = i.getAttribute("align"); - } - var f = {}; - var d = i.getElementsByTagName("param"); - var k = d.length; - for (var j = 0; j < k; j++) { - if (d[j].getAttribute("name").toLowerCase() != "movie") { - f[d[j].getAttribute("name")] = d[j].getAttribute("value"); - } - } - ae(e, f, c, l); - } else { - aF(i); - if (l) { - l(a); - } - } - } - } - } else { - ay(c, true); - if (l) { - var b = av(c); - if (b && typeof b.SetVariable != aq) { - a.success = true; - a.ref = b; - } - l(a); - } - } - } - } - } - function av(b) { - var d = null; - var c = aS(b); - if (c && c.nodeName == "OBJECT") { - if (typeof c.SetVariable != aq) { - d = c; - } else { - var a = c.getElementsByTagName(aD)[0]; - if (a) { - d = a; - } - } - } - return d; - } - function au() { - return !aU && ao("6.0.65") && (ah.win || ah.mac) && !(ah.wk && ah.wk < 312); - } - function ae(f, d, h, e) { - aU = true; - ap = e || null; - at = { - success: false, - id: h - }; - var a = aS(h); - if (a) { - if (a.nodeName == "OBJECT") { - aJ = aO(a); - ad = null; - } else { - aJ = a; - ad = h; - } - f.id = ac; - if (typeof f.width == aq || (!/%$/.test(f.width) && parseInt(f.width, 10) < 310)) { - f.width = "310"; - } - if (typeof f.height == aq || (!/%$/.test(f.height) && parseInt(f.height, 10) < 137)) { - f.height = "137"; - } - aL.title = aL.title.slice(0, 47) + " - Flash Player Installation"; - var b = ah.ie && ah.win ? "ActiveX" : "PlugIn", - c = "MMredirectURL=" + af.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + b + "&MMdoctitle=" + aL.title; - if (typeof d.flashvars != aq) { - d.flashvars += "&" + c; - } else { - d.flashvars = c; - } - if (ah.ie && ah.win && a.readyState != 4) { - var g = ar("div"); - h += "SWFObjectNew"; - g.setAttribute("id", h); - a.parentNode.insertBefore(g, a); - a.style.display = "none"; - (function () { - if (a.readyState == 4) { - a.parentNode.removeChild(a); - } else { - setTimeout(arguments.callee, 10); - } - })(); - } - aA(f, d, h); - } - } - function aF(a) { - if (ah.ie && ah.win && a.readyState != 4) { - var b = ar("div"); - a.parentNode.insertBefore(b, a); - b.parentNode.replaceChild(aO(a), b); - a.style.display = "none"; - (function () { - if (a.readyState == 4) { - a.parentNode.removeChild(a); - } else { - setTimeout(arguments.callee, 10); - } - })(); - } else { - a.parentNode.replaceChild(aO(a), a); - } - } - function aO(b) { - var d = ar("div"); - if (ah.win && ah.ie) { - d.innerHTML = b.innerHTML; - } else { - var e = b.getElementsByTagName(aD)[0]; - if (e) { - var a = e.childNodes; - if (a) { - var f = a.length; - for (var c = 0; c < f; c++) { - if (!(a[c].nodeType == 1 && a[c].nodeName == "PARAM") && !(a[c].nodeType == 8)) { - d.appendChild(a[c].cloneNode(true)); - } - } - } - } - } - return d; - } - function aA(e, g, c) { - var d, a = aS(c); - if (ah.wk && ah.wk < 312) { - return d; - } - if (a) { - if (typeof e.id == aq) { - e.id = c; - } - if (ah.ie && ah.win) { - var f = ""; - for (var i in e) { - if (e[i] != Object.prototype[i]) { - if (i.toLowerCase() == "data") { - g.movie = e[i]; - } else { - if (i.toLowerCase() == "styleclass") { - f += ' class="' + e[i] + '"'; - } else { - if (i.toLowerCase() != "classid") { - f += " " + i + '="' + e[i] + '"'; - } - } - } - } - } - var h = ""; - for (var j in g) { - if (g[j] != Object.prototype[j]) { - h += ''; - } - } - a.outerHTML = '" + h + ""; - ag[ag.length] = e.id; - d = aS(e.id); - } else { - var b = ar(aD); - b.setAttribute("type", aE); - for (var k in e) { - if (e[k] != Object.prototype[k]) { - if (k.toLowerCase() == "styleclass") { - b.setAttribute("class", e[k]); - } else { - if (k.toLowerCase() != "classid") { - b.setAttribute(k, e[k]); - } - } - } - } - for (var l in g) { - if (g[l] != Object.prototype[l] && l.toLowerCase() != "movie") { - aQ(b, l, g[l]); - } - } - a.parentNode.replaceChild(b, a); - d = b; - } - } - return d; - } - function aQ(b, d, c) { - var a = ar("param"); - a.setAttribute("name", d); - a.setAttribute("value", c); - b.appendChild(a); - } - function aw(a) { - var b = aS(a); - if (b && b.nodeName == "OBJECT") { - if (ah.ie && ah.win) { - b.style.display = "none"; - (function () { - if (b.readyState == 4) { - aT(a); - } else { - setTimeout(arguments.callee, 10); - } - })(); - } else { - b.parentNode.removeChild(b); - } - } - } - function aT(a) { - var b = aS(a); - if (b) { - for (var c in b) { - if (typeof b[c] == "function") { - b[c] = null; - } - } - b.parentNode.removeChild(b); - } - } - function aS(a) { - var c = null; - try { - c = aL.getElementById(a); - } catch (b) {} - return c; - } - function ar(a) { - return aL.createElement(a); - } - function aM(a, c, b) { - a.attachEvent(c, b); - al[al.length] = [a, c, b]; - } - function ao(a) { - var b = ah.pv, - c = a.split("."); - c[0] = parseInt(c[0], 10); - c[1] = parseInt(c[1], 10) || 0; - c[2] = parseInt(c[2], 10) || 0; - return (b[0] > c[0] || (b[0] == c[0] && b[1] > c[1]) || (b[0] == c[0] && b[1] == c[1] && b[2] >= c[2])) ? true : false; - } - function az(b, f, a, c) { - if (ah.ie && ah.mac) { - return; - } - var e = aL.getElementsByTagName("head")[0]; - if (!e) { - return; - } - var g = (a && typeof a == "string") ? a : "screen"; - if (c) { - aH = null; - an = null; - } - if (!aH || an != g) { - var d = ar("style"); - d.setAttribute("type", "text/css"); - d.setAttribute("media", g); - aH = e.appendChild(d); - if (ah.ie && ah.win && typeof aL.styleSheets != aq && aL.styleSheets.length > 0) { - aH = aL.styleSheets[aL.styleSheets.length - 1]; - } - an = g; - } - if (ah.ie && ah.win) { - if (aH && typeof aH.addRule == aD) { - aH.addRule(b, f); - } - } else { - if (aH && typeof aL.createTextNode != aq) { - aH.appendChild(aL.createTextNode(b + " {" + f + "}")); - } - } - } - function ay(a, c) { - if (!aI) { - return; - } - var b = c ? "visible" : "hidden"; - if (ak && aS(a)) { - aS(a).style.visibility = b; - } else { - az("#" + a, "visibility:" + b); - } - } - function ai(b) { - var a = /[\\\"<>\.;]/; - var c = a.exec(b) != null; - return c && typeof encodeURIComponent != aq ? encodeURIComponent(b) : b; - } - var aR = function () { - if (ah.ie && ah.win) { - window.attachEvent("onunload", function () { - var a = al.length; - for (var b = 0; b < a; b++) { - al[b][0].detachEvent(al[b][1], al[b][2]); - } - var d = ag.length; - for (var c = 0; c < d; c++) { - aw(ag[c]); - } - for (var e in ah) { - ah[e] = null; - } - ah = null; - for (var f in swfobject) { - swfobject[f] = null; - } - swfobject = null; - }); - } - }(); - return { - registerObject: function (a, e, c, b) { - if (ah.w3 && a && e) { - var d = {}; - d.id = a; - d.swfVersion = e; - d.expressInstall = c; - d.callbackFn = b; - aG[aG.length] = d; - ay(a, false); - } else { - if (b) { - b({ - success: false, - id: a - }); - } - } - }, - getObjectById: function (a) { - if (ah.w3) { - return av(a); - } - }, - embedSWF: function (k, e, h, f, c, a, b, i, g, j) { - var d = { - success: false, - id: e - }; - if (ah.w3 && !(ah.wk && ah.wk < 312) && k && e && h && f && c) { - ay(e, false); - aj(function () { - h += ""; - f += ""; - var q = {}; - if (g && typeof g === aD) { - for (var o in g) { - q[o] = g[o]; - } - } - q.data = k; - q.width = h; - q.height = f; - var n = {}; - if (i && typeof i === aD) { - for (var p in i) { - n[p] = i[p]; - } - } - if (b && typeof b === aD) { - for (var l in b) { - if (typeof n.flashvars != aq) { - n.flashvars += "&" + l + "=" + b[l]; - } else { - n.flashvars = l + "=" + b[l]; - } - } - } - if (ao(c)) { - var m = aA(q, n, e); - if (q.id == e) { - ay(e, true); - } - d.success = true; - d.ref = m; - } else { - if (a && au()) { - q.data = a; - ae(q, n, e, j); - return; - } else { - ay(e, true); - } - } - if (j) { - j(d); - } - }); - } else { - if (j) { - j(d); - } - } - }, - switchOffAutoHideShow: function () { - aI = false; - }, - ua: ah, - getFlashPlayerVersion: function () { - return { - major: ah.pv[0], - minor: ah.pv[1], - release: ah.pv[2] - }; - }, - hasFlashPlayerVersion: ao, - createSWF: function (a, b, c) { - if (ah.w3) { - return aA(a, b, c); - } else { - return undefined; - } - }, - showExpressInstall: function (b, a, d, c) { - if (ah.w3 && au()) { - ae(b, a, d, c); - } - }, - removeSWF: function (a) { - if (ah.w3) { - aw(a); - } - }, - createCSS: function (b, a, c, d) { - if (ah.w3) { - az(b, a, c, d); - } - }, - addDomLoadEvent: aj, - addLoadEvent: aC, - getQueryParamValue: function (b) { - var a = aL.location.search || aL.location.hash; - if (a) { - if (/\?/.test(a)) { - a = a.split("?")[1]; - } - if (b == null) { - return ai(a); - } - var c = a.split("&"); - for (var d = 0; d < c.length; d++) { - if (c[d].substring(0, c[d].indexOf("=")) == b) { - return ai(c[d].substring((c[d].indexOf("=") + 1))); - } - } - } - return ""; - }, - expressInstallCallback: function () { - if (aU) { - var a = aS(ac); - if (a && aJ) { - a.parentNode.replaceChild(aJ, a); - if (ad) { - ay(ad, true); - if (ah.ie && ah.win) { - aJ.style.display = "block"; - } - } - if (ap) { - ap(at); - } - } - aU = false; - } - } - }; -}(); -var SWFUpload; -if (SWFUpload == undefined) { - SWFUpload = function (b) { - this.initSWFUpload(b); - }; -} -SWFUpload.prototype.initSWFUpload = function (c) { - try { - this.customSettings = {}; - this.settings = c; - this.eventQueue = []; - this.movieName = "SWFUpload_" + SWFUpload.movieCount++; - this.movieElement = null; - SWFUpload.instances[this.movieName] = this; - this.initSettings(); - this.loadFlash(); - this.displayDebugInfo(); - } catch (d) { - delete SWFUpload.instances[this.movieName]; - throw d; - } -}; -SWFUpload.instances = {}; -SWFUpload.movieCount = 0; -SWFUpload.version = "2.2.0 2009-03-25"; -SWFUpload.QUEUE_ERROR = { - QUEUE_LIMIT_EXCEEDED: -100, - FILE_EXCEEDS_SIZE_LIMIT: -110, - ZERO_BYTE_FILE: -120, - INVALID_FILETYPE: -130 -}; -SWFUpload.UPLOAD_ERROR = { - HTTP_ERROR: -200, - MISSING_UPLOAD_URL: -210, - IO_ERROR: -220, - SECURITY_ERROR: -230, - UPLOAD_LIMIT_EXCEEDED: -240, - UPLOAD_FAILED: -250, - SPECIFIED_FILE_ID_NOT_FOUND: -260, - FILE_VALIDATION_FAILED: -270, - FILE_CANCELLED: -280, - UPLOAD_STOPPED: -290 -}; -SWFUpload.FILE_STATUS = { - QUEUED: -1, - IN_PROGRESS: -2, - ERROR: -3, - COMPLETE: -4, - CANCELLED: -5 -}; -SWFUpload.BUTTON_ACTION = { - SELECT_FILE: -100, - SELECT_FILES: -110, - START_UPLOAD: -120 -}; -SWFUpload.CURSOR = { - ARROW: -1, - HAND: -2 -}; -SWFUpload.WINDOW_MODE = { - WINDOW: "window", - TRANSPARENT: "transparent", - OPAQUE: "opaque" -}; -SWFUpload.completeURL = function (e) { - if (typeof(e) !== "string" || e.match(/^https?:\/\//i) || e.match(/^\//)) { - return e; - } - var f = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); - var d = window.location.pathname.lastIndexOf("/"); - if (d <= 0) { - path = "/"; - } else { - path = window.location.pathname.substr(0, d) + "/"; - } - return path + e; -}; -SWFUpload.prototype.initSettings = function () { - this.ensureDefault = function (c, d) { - this.settings[c] = (this.settings[c] == undefined) ? d : this.settings[c]; - }; - this.ensureDefault("upload_url", ""); - this.ensureDefault("preserve_relative_urls", false); - this.ensureDefault("file_post_name", "Filedata"); - this.ensureDefault("post_params", {}); - this.ensureDefault("use_query_string", false); - this.ensureDefault("requeue_on_error", false); - this.ensureDefault("http_success", []); - this.ensureDefault("assume_success_timeout", 0); - this.ensureDefault("file_types", "*.*"); - this.ensureDefault("file_types_description", "All Files"); - this.ensureDefault("file_size_limit", 0); - this.ensureDefault("file_upload_limit", 0); - this.ensureDefault("file_queue_limit", 0); - this.ensureDefault("flash_url", "swfupload.swf"); - this.ensureDefault("prevent_swf_caching", true); - this.ensureDefault("button_image_url", ""); - this.ensureDefault("button_width", 1); - this.ensureDefault("button_height", 1); - this.ensureDefault("button_text", ""); - this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); - this.ensureDefault("button_text_top_padding", 0); - this.ensureDefault("button_text_left_padding", 0); - this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); - this.ensureDefault("button_disabled", false); - this.ensureDefault("button_placeholder_id", ""); - this.ensureDefault("button_placeholder", null); - this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); - this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); - this.ensureDefault("debug", false); - this.settings.debug_enabled = this.settings.debug; - this.settings.return_upload_start_handler = this.returnUploadStart; - this.ensureDefault("swfupload_loaded_handler", null); - this.ensureDefault("file_dialog_start_handler", null); - this.ensureDefault("file_queued_handler", null); - this.ensureDefault("file_queue_error_handler", null); - this.ensureDefault("file_dialog_complete_handler", null); - this.ensureDefault("upload_start_handler", null); - this.ensureDefault("upload_progress_handler", null); - this.ensureDefault("upload_error_handler", null); - this.ensureDefault("upload_success_handler", null); - this.ensureDefault("upload_complete_handler", null); - this.ensureDefault("debug_handler", this.debugMessage); - this.ensureDefault("custom_settings", {}); - this.customSettings = this.settings.custom_settings; - if ( !! this.settings.prevent_swf_caching) { - this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); - } - if (!this.settings.preserve_relative_urls) { - this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); - this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); - } - delete this.ensureDefault; -}; -SWFUpload.prototype.loadFlash = function () { - var d, c; - if (document.getElementById(this.movieName) !== null) { - throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; - } - d = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; - if (d == undefined) { - throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; - } - c = document.createElement("div"); - c.innerHTML = this.getFlashHTML(); - d.parentNode.replaceChild(c.firstChild, d); - if (window[this.movieName] == undefined) { - window[this.movieName] = this.getMovieElement(); - } -}; -SWFUpload.prototype.getFlashHTML = function () { - return ['', '', '', '', '', '', '', ""].join(""); -}; -SWFUpload.prototype.getFlashVars = function () { - var c = this.buildParamString(); - var d = this.settings.http_success.join(","); - return ["movieName=", encodeURIComponent(this.movieName), "&uploadURL=", encodeURIComponent(this.settings.upload_url), "&useQueryString=", encodeURIComponent(this.settings.use_query_string), "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&httpSuccess=", encodeURIComponent(d), "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&params=", encodeURIComponent(c), "&filePostName=", encodeURIComponent(this.settings.file_post_name), "&fileTypes=", encodeURIComponent(this.settings.file_types), "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&buttonWidth=", encodeURIComponent(this.settings.button_width), "&buttonHeight=", encodeURIComponent(this.settings.button_height), "&buttonText=", encodeURIComponent(this.settings.button_text), "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&buttonAction=", encodeURIComponent(this.settings.button_action), "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join(""); -}; -SWFUpload.prototype.getMovieElement = function () { - if (this.movieElement == undefined) { - this.movieElement = document.getElementById(this.movieName); - } - if (this.movieElement === null) { - throw "Could not find Flash element"; - } - return this.movieElement; -}; -SWFUpload.prototype.buildParamString = function () { - var f = this.settings.post_params; - var d = []; - if (typeof(f) === "object") { - for (var e in f) { - if (f.hasOwnProperty(e)) { - d.push(encodeURIComponent(e.toString()) + "=" + encodeURIComponent(f[e].toString())); - } - } - } - return d.join("&"); -}; -SWFUpload.prototype.destroy = function () { - try { - this.cancelUpload(null, false); - var g = null; - g = this.getMovieElement(); - if (g && typeof(g.CallFunction) === "unknown") { - for (var j in g) { - try { - if (typeof(g[j]) === "function") { - g[j] = null; - } - } catch (h) {} - } - try { - g.parentNode.removeChild(g); - } catch (f) {} - } - window[this.movieName] = null; - SWFUpload.instances[this.movieName] = null; - delete SWFUpload.instances[this.movieName]; - this.movieElement = null; - this.settings = null; - this.customSettings = null; - this.eventQueue = null; - this.movieName = null; - return true; - } catch (i) { - return false; - } -}; -SWFUpload.prototype.displayDebugInfo = function () { - this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", "\t", "upload_url: ", this.settings.upload_url, "\n", "\t", "flash_url: ", this.settings.flash_url, "\n", "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", "\t", "http_success: ", this.settings.http_success.join(", "), "\n", "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", "\t", "file_post_name: ", this.settings.file_post_name, "\n", "\t", "post_params: ", this.settings.post_params.toString(), "\n", "\t", "file_types: ", this.settings.file_types, "\n", "\t", "file_types_description: ", this.settings.file_types_description, "\n", "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", "\t", "debug: ", this.settings.debug.toString(), "\n", "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", "\t", "button_width: ", this.settings.button_width.toString(), "\n", "\t", "button_height: ", this.settings.button_height.toString(), "\n", "\t", "button_text: ", this.settings.button_text.toString(), "\n", "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", "\t", "button_action: ", this.settings.button_action.toString(), "\n", "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"].join("")); -}; -SWFUpload.prototype.addSetting = function (d, f, e) { - if (f == undefined) { - return (this.settings[d] = e); - } else { - return (this.settings[d] = f); - } -}; -SWFUpload.prototype.getSetting = function (b) { - if (this.settings[b] != undefined) { - return this.settings[b]; - } - return ""; -}; -SWFUpload.prototype.callFlash = function (functionName, argumentArray) { - argumentArray = argumentArray || []; - var movieElement = this.getMovieElement(); - var returnValue, returnString; - try { - returnString = movieElement.CallFunction('' + __flash__argumentsToXML(argumentArray, 0) + ""); - returnValue = eval(returnString); - } catch (ex) { - throw "Call to " + functionName + " failed"; - } - if (returnValue != undefined && typeof returnValue.post === "object") { - returnValue = this.unescapeFilePostParams(returnValue); - } - return returnValue; -}; -SWFUpload.prototype.selectFile = function () { - this.callFlash("SelectFile"); -}; -SWFUpload.prototype.selectFiles = function () { - this.callFlash("SelectFiles"); -}; -SWFUpload.prototype.startUpload = function (b) { - this.callFlash("StartUpload", [b]); -}; -SWFUpload.prototype.cancelUpload = function (d, c) { - if (c !== false) { - c = true; - } - this.callFlash("CancelUpload", [d, c]); -}; -SWFUpload.prototype.stopUpload = function () { - this.callFlash("StopUpload"); -}; -SWFUpload.prototype.getStats = function () { - return this.callFlash("GetStats"); -}; -SWFUpload.prototype.setStats = function (b) { - this.callFlash("SetStats", [b]); -}; -SWFUpload.prototype.getFile = function (b) { - if (typeof(b) === "number") { - return this.callFlash("GetFileByIndex", [b]); - } else { - return this.callFlash("GetFile", [b]); - } -}; -SWFUpload.prototype.addFileParam = function (e, d, f) { - return this.callFlash("AddFileParam", [e, d, f]); -}; -SWFUpload.prototype.removeFileParam = function (d, c) { - this.callFlash("RemoveFileParam", [d, c]); -}; -SWFUpload.prototype.setUploadURL = function (b) { - this.settings.upload_url = b.toString(); - this.callFlash("SetUploadURL", [b]); -}; -SWFUpload.prototype.setPostParams = function (b) { - this.settings.post_params = b; - this.callFlash("SetPostParams", [b]); -}; -SWFUpload.prototype.addPostParam = function (d, c) { - this.settings.post_params[d] = c; - this.callFlash("SetPostParams", [this.settings.post_params]); -}; -SWFUpload.prototype.removePostParam = function (b) { - delete this.settings.post_params[b]; - this.callFlash("SetPostParams", [this.settings.post_params]); -}; -SWFUpload.prototype.setFileTypes = function (d, c) { - this.settings.file_types = d; - this.settings.file_types_description = c; - this.callFlash("SetFileTypes", [d, c]); -}; -SWFUpload.prototype.setFileSizeLimit = function (b) { - this.settings.file_size_limit = b; - this.callFlash("SetFileSizeLimit", [b]); -}; -SWFUpload.prototype.setFileUploadLimit = function (b) { - this.settings.file_upload_limit = b; - this.callFlash("SetFileUploadLimit", [b]); -}; -SWFUpload.prototype.setFileQueueLimit = function (b) { - this.settings.file_queue_limit = b; - this.callFlash("SetFileQueueLimit", [b]); -}; -SWFUpload.prototype.setFilePostName = function (b) { - this.settings.file_post_name = b; - this.callFlash("SetFilePostName", [b]); -}; -SWFUpload.prototype.setUseQueryString = function (b) { - this.settings.use_query_string = b; - this.callFlash("SetUseQueryString", [b]); -}; -SWFUpload.prototype.setRequeueOnError = function (b) { - this.settings.requeue_on_error = b; - this.callFlash("SetRequeueOnError", [b]); -}; -SWFUpload.prototype.setHTTPSuccess = function (b) { - if (typeof b === "string") { - b = b.replace(" ", "").split(","); - } - this.settings.http_success = b; - this.callFlash("SetHTTPSuccess", [b]); -}; -SWFUpload.prototype.setAssumeSuccessTimeout = function (b) { - this.settings.assume_success_timeout = b; - this.callFlash("SetAssumeSuccessTimeout", [b]); -}; -SWFUpload.prototype.setDebugEnabled = function (b) { - this.settings.debug_enabled = b; - this.callFlash("SetDebugEnabled", [b]); -}; -SWFUpload.prototype.setButtonImageURL = function (b) { - if (b == undefined) { - b = ""; - } - this.settings.button_image_url = b; - this.callFlash("SetButtonImageURL", [b]); -}; -SWFUpload.prototype.setButtonDimensions = function (f, e) { - this.settings.button_width = f; - this.settings.button_height = e; - var d = this.getMovieElement(); - if (d != undefined) { - d.style.width = f + "px"; - d.style.height = e + "px"; - } - this.callFlash("SetButtonDimensions", [f, e]); -}; -SWFUpload.prototype.setButtonText = function (b) { - this.settings.button_text = b; - this.callFlash("SetButtonText", [b]); -}; -SWFUpload.prototype.setButtonTextPadding = function (c, d) { - this.settings.button_text_top_padding = d; - this.settings.button_text_left_padding = c; - this.callFlash("SetButtonTextPadding", [c, d]); -}; -SWFUpload.prototype.setButtonTextStyle = function (b) { - this.settings.button_text_style = b; - this.callFlash("SetButtonTextStyle", [b]); -}; -SWFUpload.prototype.setButtonDisabled = function (b) { - this.settings.button_disabled = b; - this.callFlash("SetButtonDisabled", [b]); -}; -SWFUpload.prototype.setButtonAction = function (b) { - this.settings.button_action = b; - this.callFlash("SetButtonAction", [b]); -}; -SWFUpload.prototype.setButtonCursor = function (b) { - this.settings.button_cursor = b; - this.callFlash("SetButtonCursor", [b]); -}; -SWFUpload.prototype.queueEvent = function (d, f) { - if (f == undefined) { - f = []; - } else { - if (!(f instanceof Array)) { - f = [f]; - } - } - var e = this; - if (typeof this.settings[d] === "function") { - this.eventQueue.push(function () { - this.settings[d].apply(this, f); - }); - setTimeout(function () { - e.executeNextEvent(); - }, 0); - } else { - if (this.settings[d] !== null) { - throw "Event handler " + d + " is unknown or is not a function"; - } - } -}; -SWFUpload.prototype.executeNextEvent = function () { - var b = this.eventQueue ? this.eventQueue.shift() : null; - if (typeof(b) === "function") { - b.apply(this); - } -}; -SWFUpload.prototype.unescapeFilePostParams = function (l) { - var j = /[$]([0-9a-f]{4})/i; - var i = {}; - var k; - if (l != undefined) { - for (var h in l.post) { - if (l.post.hasOwnProperty(h)) { - k = h; - var g; - while ((g = j.exec(k)) !== null) { - k = k.replace(g[0], String.fromCharCode(parseInt("0x" + g[1], 16))); - } - i[k] = l.post[h]; - } - } - l.post = i; - } - return l; -}; -SWFUpload.prototype.testExternalInterface = function () { - try { - return this.callFlash("TestExternalInterface"); - } catch (b) { - return false; - } -}; -SWFUpload.prototype.flashReady = function () { - var b = this.getMovieElement(); - if (!b) { - this.debug("Flash called back ready but the flash movie can't be found."); - return; - } - this.cleanUp(b); - this.queueEvent("swfupload_loaded_handler"); -}; -SWFUpload.prototype.cleanUp = function (f) { - try { - if (this.movieElement && typeof(f.CallFunction) === "unknown") { - this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); - for (var h in f) { - try { - if (typeof(f[h]) === "function") { - f[h] = null; - } - } catch (e) {} - } - } - } catch (g) {} - window.__flash__removeCallback = function (c, b) { - try { - if (c) { - c[b] = null; - } - } catch (a) {} - }; -}; -SWFUpload.prototype.fileDialogStart = function () { - this.queueEvent("file_dialog_start_handler"); -}; -SWFUpload.prototype.fileQueued = function (b) { - b = this.unescapeFilePostParams(b); - this.queueEvent("file_queued_handler", b); -}; -SWFUpload.prototype.fileQueueError = function (e, f, d) { - e = this.unescapeFilePostParams(e); - this.queueEvent("file_queue_error_handler", [e, f, d]); -}; -SWFUpload.prototype.fileDialogComplete = function (d, f, e) { - this.queueEvent("file_dialog_complete_handler", [d, f, e]); -}; -SWFUpload.prototype.uploadStart = function (b) { - b = this.unescapeFilePostParams(b); - this.queueEvent("return_upload_start_handler", b); -}; -SWFUpload.prototype.returnUploadStart = function (d) { - var c; - if (typeof this.settings.upload_start_handler === "function") { - d = this.unescapeFilePostParams(d); - c = this.settings.upload_start_handler.call(this, d); - } else { - if (this.settings.upload_start_handler != undefined) { - throw "upload_start_handler must be a function"; - } - } - if (c === undefined) { - c = true; - } - c = !! c; - this.callFlash("ReturnUploadStart", [c]); -}; -SWFUpload.prototype.uploadProgress = function (e, f, d) { - e = this.unescapeFilePostParams(e); - this.queueEvent("upload_progress_handler", [e, f, d]); -}; -SWFUpload.prototype.uploadError = function (e, f, d) { - e = this.unescapeFilePostParams(e); - this.queueEvent("upload_error_handler", [e, f, d]); -}; -SWFUpload.prototype.uploadSuccess = function (d, e, f) { - d = this.unescapeFilePostParams(d); - this.queueEvent("upload_success_handler", [d, e, f]); -}; -SWFUpload.prototype.uploadComplete = function (b) { - b = this.unescapeFilePostParams(b); - this.queueEvent("upload_complete_handler", b); -}; -SWFUpload.prototype.debug = function (b) { - this.queueEvent("debug_handler", b); -}; -SWFUpload.prototype.debugMessage = function (h) { - if (this.settings.debug) { - var f, g = []; - if (typeof h === "object" && typeof h.name === "string" && typeof h.message === "string") { - for (var e in h) { - if (h.hasOwnProperty(e)) { - g.push(e + ": " + h[e]); - } - } - f = g.join("\n") || ""; - g = f.split("\n"); - f = "EXCEPTION: " + g.join("\nEXCEPTION: "); - SWFUpload.Console.writeLine(f); - } else { - SWFUpload.Console.writeLine(h); - } - } -}; -SWFUpload.Console = {}; -SWFUpload.Console.writeLine = function (g) { - var e, f; - try { - e = document.getElementById("SWFUpload_Console"); - if (!e) { - f = document.createElement("form"); - document.getElementsByTagName("body")[0].appendChild(f); - e = document.createElement("textarea"); - e.id = "SWFUpload_Console"; - e.style.fontFamily = "monospace"; - e.setAttribute("wrap", "off"); - e.wrap = "off"; - e.style.overflow = "auto"; - e.style.width = "700px"; - e.style.height = "350px"; - e.style.margin = "5px"; - f.appendChild(e); - } - e.value += g + "\n"; - e.scrollTop = e.scrollHeight - e.clientHeight; - } catch (h) { - alert("Exception: " + h.name + " Message: " + h.message); - } -}; -(function (c) { - var b = { - init: function (d, e) { - return this.each(function () { - var n = c(this); - var m = n.clone(); - var j = c.extend({ - id: n.attr("id"), - swf: "uploadify.swf", - uploader: "uploadify.php", - auto: true, - buttonClass: "", - buttonCursor: "hand", - buttonImage: null, - buttonText: "SELECT FILES", - checkExisting: false, - debug: false, - fileObjName: "Filedata", - fileSizeLimit: 0, - fileTypeDesc: "All Files", - fileTypeExts: "*.*", - height: 30, - method: "post", - multi: true, - formData: {}, - preventCaching: true, - progressData: "percentage", - queueID: false, - queueSizeLimit: 999, - removeCompleted: true, - removeTimeout: 3, - requeueErrors: false, - successTimeout: 30, - uploadLimit: 0, - width: 120, - overrideEvents: [] - }, d); - var g = { - assume_success_timeout: j.successTimeout, - button_placeholder_id: j.id, - button_width: j.width, - button_height: j.height, - button_text: null, - button_text_style: null, - button_text_top_padding: 0, - button_text_left_padding: 0, - button_action: (j.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE), - button_disabled: false, - button_cursor: (j.buttonCursor == "arrow" ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND), - button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, - debug: j.debug, - requeue_on_error: j.requeueErrors, - file_post_name: j.fileObjName, - file_size_limit: j.fileSizeLimit, - file_types: j.fileTypeExts, - file_types_description: j.fileTypeDesc, - file_queue_limit: j.queueSizeLimit, - file_upload_limit: j.uploadLimit, - flash_url: j.swf, - prevent_swf_caching: j.preventCaching, - post_params: j.formData, - upload_url: j.uploader, - use_query_string: (j.method == "get"), - file_dialog_complete_handler: a.onDialogClose, - file_dialog_start_handler: a.onDialogOpen, - file_queued_handler: a.onSelect, - file_queue_error_handler: a.onSelectError, - swfupload_loaded_handler: j.onSWFReady, - upload_complete_handler: a.onUploadComplete, - upload_error_handler: a.onUploadError, - upload_progress_handler: a.onUploadProgress, - upload_start_handler: a.onUploadStart, - upload_success_handler: a.onUploadSuccess - }; - if (e) { - g = c.extend(g, e); - } - g = c.extend(g, j); - var o = swfobject.getFlashPlayerVersion(); - var h = (o.major >= 9); - if (h) { - window["uploadify_" + j.id] = new SWFUpload(g); - var i = window["uploadify_" + j.id]; - n.data("uploadify", i); - var l = c("
", { - id: j.id, - "class": "uploadify", - css: { - height: j.height + "px", - width: j.width + "px" - } - }); - c("#" + i.movieName).wrap(l); - l = c("#" + j.id); - l.data("uploadify", i); - var f = c("
", { - id: j.id + "-button", - "class": "uploadify-button " + j.buttonClass - }); - if (j.buttonImage) { - f.css({ - "background-image": "url('" + j.buttonImage + "')", - "text-indent": "-9999px" - }); - } - f.html('' + j.buttonText + "").css({ - height: j.height + "px", - "line-height": j.height + "px", - width: j.width + "px" - }); - l.append(f); - c("#" + i.movieName).css({ - position: "absolute", - "z-index": 1 - }); - if (!j.queueID) { - var k = c("
", { - id: j.id + "-queue", - "class": "uploadify-queue" - }); - l.after(k); - i.settings.queueID = j.id + "-queue"; - i.settings.defaultQueue = true; - } - i.queueData = { - files: {}, - filesSelected: 0, - filesQueued: 0, - filesReplaced: 0, - filesCancelled: 0, - filesErrored: 0, - uploadsSuccessful: 0, - uploadsErrored: 0, - averageSpeed: 0, - queueLength: 0, - queueSize: 0, - uploadSize: 0, - queueBytesUploaded: 0, - uploadQueue: [], - errorMsg: "Some files were not added to the queue:" - }; - i.original = m; - i.wrapper = l; - i.button = f; - i.queue = k; - if (j.onInit) { - j.onInit.call(n, i); - } - } else { - if (j.onFallback) { - j.onFallback.call(n); - } - } - }); - }, - cancel: function (d, f) { - var e = arguments; - this.each(function () { - var l = c(this), - i = l.data("uploadify"), - j = i.settings, - h = -1; - if (e[0]) { - if (e[0] == "*") { - var g = i.queueData.queueLength; - c("#" + j.queueID).find(".uploadify-queue-item").each(function () { - h++; - if (e[1] === true) { - i.cancelUpload(c(this).attr("id"), false); - } else { - i.cancelUpload(c(this).attr("id")); - } - c(this).find(".data").removeClass("data").html(" - Cancelled"); - c(this).find(".uploadify-progress-bar").remove(); - c(this).delay(1000 + 100 * h).fadeOut(500, function () { - c(this).remove(); - }); - }); - i.queueData.queueSize = 0; - i.queueData.queueLength = 0; - if (j.onClearQueue) { - j.onClearQueue.call(l, g); - } - } else { - for (var m = 0; m < e.length; m++) { - i.cancelUpload(e[m]); - c("#" + e[m]).find(".data").removeClass("data").html(" - Cancelled"); - c("#" + e[m]).find(".uploadify-progress-bar").remove(); - c("#" + e[m]).delay(1000 + 100 * m).fadeOut(500, function () { - c(this).remove(); - }); - } - } - } else { - var k = c("#" + j.queueID).find(".uploadify-queue-item").get(0); - $item = c(k); - i.cancelUpload($item.attr("id")); - $item.find(".data").removeClass("data").html(" - Cancelled"); - $item.find(".uploadify-progress-bar").remove(); - $item.delay(1000).fadeOut(500, function () { - c(this).remove(); - }); - } - }); - }, - destroy: function () { - this.each(function () { - var f = c(this), - d = f.data("uploadify"), - e = d.settings; - d.destroy(); - if (e.defaultQueue) { - c("#" + e.queueID).remove(); - } - c("#" + e.id).replaceWith(d.original); - if (e.onDestroy) { - e.onDestroy.call(this); - } - delete d; - }); - }, - disable: function (d) { - this.each(function () { - var g = c(this), - e = g.data("uploadify"), - f = e.settings; - if (d) { - e.button.addClass("disabled"); - if (f.onDisable) { - f.onDisable.call(this); - } - } else { - e.button.removeClass("disabled"); - if (f.onEnable) { - f.onEnable.call(this); - } - } - e.setButtonDisabled(d); - }); - }, - settings: function (e, g, h) { - var d = arguments; - var f = g; - this.each(function () { - var k = c(this), - i = k.data("uploadify"), - j = i.settings; - if (typeof(d[0]) == "object") { - for (var l in g) { - setData(l, g[l]); - } - } - if (d.length === 1) { - f = j[e]; - } else { - switch (e) { - case "uploader": - i.setUploadURL(g); - break; - case "formData": - if (!h) { - g = c.extend(j.formData, g); - } - i.setPostParams(j.formData); - break; - case "method": - if (g == "get") { - i.setUseQueryString(true); - } else { - i.setUseQueryString(false); - } - break; - case "fileObjName": - i.setFilePostName(g); - break; - case "fileTypeExts": - i.setFileTypes(g, j.fileTypeDesc); - break; - case "fileTypeDesc": - i.setFileTypes(j.fileTypeExts, g); - break; - case "fileSizeLimit": - i.setFileSizeLimit(g); - break; - case "uploadLimit": - i.setFileUploadLimit(g); - break; - case "queueSizeLimit": - i.setFileQueueLimit(g); - break; - case "buttonImage": - i.button.css("background-image", settingValue); - break; - case "buttonCursor": - if (g == "arrow") { - i.setButtonCursor(SWFUpload.CURSOR.ARROW); - } else { - i.setButtonCursor(SWFUpload.CURSOR.HAND); - } - break; - case "buttonText": - c("#" + j.id + "-button").find(".uploadify-button-text").html(g); - break; - case "width": - i.setButtonDimensions(g, j.height); - break; - case "height": - i.setButtonDimensions(j.width, g); - break; - case "multi": - if (g) { - i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES); - } else { - i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE); - } - break; - } - j[e] = g; - } - }); - if (d.length === 1) { - return f; - } - }, - stop: function () { - this.each(function () { - var e = c(this), - d = e.data("uploadify"); - d.queueData.averageSpeed = 0; - d.queueData.uploadSize = 0; - d.queueData.bytesUploaded = 0; - d.queueData.uploadQueue = []; - d.stopUpload(); - }); - }, - upload: function () { - var d = arguments; - this.each(function () { - var f = c(this), - e = f.data("uploadify"); - e.queueData.averageSpeed = 0; - e.queueData.uploadSize = 0; - e.queueData.bytesUploaded = 0; - e.queueData.uploadQueue = []; - if (d[0]) { - if (d[0] == "*") { - e.queueData.uploadSize = e.queueData.queueSize; - e.queueData.uploadQueue.push("*"); - e.startUpload(); - } else { - for (var g = 0; g < d.length; g++) { - e.queueData.uploadSize += e.queueData.files[d[g]].size; - e.queueData.uploadQueue.push(d[g]); - } - e.startUpload(e.queueData.uploadQueue.shift()); - } - } else { - e.startUpload(); - } - }); - } - }; - var a = { - onDialogOpen: function () { - var d = this.settings; - this.queueData.errorMsg = "Some files were not added to the queue:"; - this.queueData.filesReplaced = 0; - this.queueData.filesCancelled = 0; - if (d.onDialogOpen) { - d.onDialogOpen.call(this); - } - }, - onDialogClose: function (d, f, g) { - var e = this.settings; - this.queueData.filesErrored = d - f; - this.queueData.filesSelected = d; - this.queueData.filesQueued = f - this.queueData.filesCancelled; - this.queueData.queueLength = g; - if (c.inArray("onDialogClose", e.overrideEvents) < 0) { - if (this.queueData.filesErrored > 0) { - alert(this.queueData.errorMsg); - } - } - if (e.onDialogClose) { - e.onDialogClose.call(this, this.queueData); - } - if (e.auto) { - c("#" + e.id).uploadify("upload", "*"); - } - }, - onSelect: function (g) { - var h = this.settings; - var e = {}; - for (var f in this.queueData.files) { - e = this.queueData.files[f]; - if (e.uploaded != true && e.name == g.name) { - var d = confirm('The file named "' + g.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?'); - if (!d) { - this.cancelUpload(g.id); - this.queueData.filesCancelled++; - return false; - } else { - c("#" + e.id).remove(); - this.cancelUpload(e.id); - this.queueData.filesReplaced++; - } - } - } - var i = Math.round(g.size / 1024); - var l = "KB"; - if (i > 1000) { - i = Math.round(i / 1000); - l = "MB"; - } - var k = i.toString().split("."); - i = k[0]; - if (k.length > 1) { - i += "." + k[1].substr(0, 2); - } - i += l; - var j = g.name; - if (j.length > 25) { - j = j.substr(0, 25) + "..."; - } - if (c.inArray("onSelect", h.overrideEvents) < 0) { - c("#" + h.queueID).append('
X
' + j + " (" + i + ')
'); - } - this.queueData.queueSize += g.size; - this.queueData.files[g.id] = g; - if (h.onSelect) { - h.onSelect.apply(this, arguments); - } - }, - onSelectError: function (d, g, f) { - var e = this.settings; - if (c.inArray("onSelectError", e.overrideEvents) < 0) { - switch (g) { - case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: - if (e.queueSizeLimit > f) { - this.queueData.errorMsg += "\nThe number of files selected exceeds the remaining upload limit (" + f + ")."; - } else { - this.queueData.errorMsg += "\nThe number of files selected exceeds the queue size limit (" + e.queueSizeLimit + ")."; - } - break; - case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: - this.queueData.errorMsg += '\nThe file "' + d.name + '" exceeds the size limit (' + e.fileSizeLimit + ")."; - break; - case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: - this.queueData.errorMsg += '\nThe file "' + d.name + '" is empty.'; - break; - case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: - this.queueData.errorMsg += '\nThe file "' + d.name + '" is not an accepted file type (' + e.fileTypeDesc + ")."; - break; - } - } - if (g != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { - delete this.queueData.files[d.id]; - } - if (e.onSelectError) { - e.onSelectError.apply(this, arguments); - } - }, - onQueueComplete: function () { - if (this.settings.onQueueComplete) { - this.settings.onQueueComplete.call(this, this.settings.queueData); - } - }, - onUploadComplete: function (f) { - var g = this.settings, - d = this; - var e = this.getStats(); - this.queueData.queueLength = e.files_queued; - if (this.queueData.uploadQueue[0] == "*") { - if (this.queueData.queueLength > 0) { - this.startUpload(); - } else { - this.queueData.uploadQueue = []; - if (g.onQueueComplete) { - g.onQueueComplete.call(this, this.queueData); - } - } - } else { - if (this.queueData.uploadQueue.length > 0) { - this.startUpload(this.queueData.uploadQueue.shift()); - } else { - this.queueData.uploadQueue = []; - if (g.onQueueComplete) { - g.onQueueComplete.call(this, this.queueData); - } - } - } - if (c.inArray("onUploadComplete", g.overrideEvents) < 0) { - if (g.removeCompleted) { - switch (f.filestatus) { - case SWFUpload.FILE_STATUS.COMPLETE: - setTimeout(function () { - if (c("#" + f.id)) { - d.queueData.queueSize -= f.size; - d.queueData.queueLength -= 1; - delete d.queueData.files[f.id]; - c("#" + f.id).fadeOut(500, function () { - c(this).remove(); - }); - } - }, g.removeTimeout * 1000); - break; - case SWFUpload.FILE_STATUS.ERROR: - if (!g.requeueErrors) { - setTimeout(function () { - if (c("#" + f.id)) { - d.queueData.queueSize -= f.size; - d.queueData.queueLength -= 1; - delete d.queueData.files[f.id]; - c("#" + f.id).fadeOut(500, function () { - c(this).remove(); - }); - } - }, g.removeTimeout * 1000); - } - break; - } - } else { - f.uploaded = true; - } - } - if (g.onUploadComplete) { - g.onUploadComplete.call(this, f); - } - }, - onUploadError: function (e, i, h) { - var f = this.settings; - var g = "Error"; - switch (i) { - case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: - g = "HTTP Error (" + h + ")"; - break; - case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL: - g = "Missing Upload URL"; - break; - case SWFUpload.UPLOAD_ERROR.IO_ERROR: - g = "IO Error"; - break; - case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: - g = "Security Error"; - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: - alert("The upload limit has been reached (" + h + ")."); - g = "Exceeds Upload Limit"; - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: - g = "Failed"; - break; - case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND: - break; - case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: - g = "Validation Error"; - break; - case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: - g = "Cancelled"; - this.queueData.queueSize -= e.size; - this.queueData.queueLength -= 1; - if (e.status == SWFUpload.FILE_STATUS.IN_PROGRESS || c.inArray(e.id, this.queueData.uploadQueue) >= 0) { - this.queueData.uploadSize -= e.size; - } - if (f.onCancel) { - f.onCancel.call(this, e); - } - delete this.queueData.files[e.id]; - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: - g = "Stopped"; - break; - } - if (c.inArray("onUploadError", f.overrideEvents) < 0) { - if (i != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && i != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) { - c("#" + e.id).addClass("uploadify-error"); - } - c("#" + e.id).find(".uploadify-progress-bar").css("width", "1px"); - if (i != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && e.status != SWFUpload.FILE_STATUS.COMPLETE) { - c("#" + e.id).find(".data").html(" - " + g); - } - } - var d = this.getStats(); - this.queueData.uploadsErrored = d.upload_errors; - if (f.onUploadError) { - f.onUploadError.call(this, e, i, h, g); - } - }, - onUploadProgress: function (g, m, j) { - var h = this.settings; - var e = new Date(); - var n = e.getTime(); - var k = n - this.timer; - if (k > 500) { - this.timer = n; - } - var i = m - this.bytesLoaded; - this.bytesLoaded = m; - var d = this.queueData.queueBytesUploaded + m; - var p = Math.round(m / j * 100); - var o = "KB/s"; - var l = 0; - var f = (i / 1024) / (k / 1000); - f = Math.floor(f * 10) / 10; - if (this.queueData.averageSpeed > 0) { - this.queueData.averageSpeed = Math.floor((this.queueData.averageSpeed + f) / 2); - } else { - this.queueData.averageSpeed = Math.floor(f); - } - if (f > 1000) { - l = (f * 0.001); - this.queueData.averageSpeed = Math.floor(l); - o = "MB/s"; - } - if (c.inArray("onUploadProgress", h.overrideEvents) < 0) { - if (h.progressData == "percentage") { - c("#" + g.id).find(".data").html(" - " + p + "%"); - } else { - if (h.progressData == "speed" && k > 500) { - c("#" + g.id).find(".data").html(" - " + this.queueData.averageSpeed + o); - } - } - c("#" + g.id).find(".uploadify-progress-bar").css("width", p + "%"); - } - if (h.onUploadProgress) { - h.onUploadProgress.call(this, g, m, j, d, this.queueData.uploadSize); - } - }, - onUploadStart: function (d) { - var e = this.settings; - var f = new Date(); - this.timer = f.getTime(); - this.bytesLoaded = 0; - if (this.queueData.uploadQueue.length == 0) { - this.queueData.uploadSize = d.size; - } - if (e.checkExisting) { - c.ajax({ - type: "POST", - async: false, - url: e.checkExisting, - data: { - filename: d.name - }, - success: function (h) { - if (h == 1) { - var g = confirm('A file with the name "' + d.name + '" already exists on the server.\nWould you like to replace the existing file?'); - if (!g) { - this.cancelUpload(d.id); - c("#" + d.id).remove(); - if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) { - if (this.queueData.uploadQueue[0] == "*") { - this.startUpload(); - } else { - this.startUpload(this.queueData.uploadQueue.shift()); - } - } - } - } - } - }); - } - if (e.onUploadStart) { - e.onUploadStart.call(this, d); - } - }, - onUploadSuccess: function (f, h, d) { - var g = this.settings; - var e = this.getStats(); - this.queueData.uploadsSuccessful = e.successful_uploads; - this.queueData.queueBytesUploaded += f.size; - if (c.inArray("onUploadSuccess", g.overrideEvents) < 0) { - c("#" + f.id).find(".data").html(" - Complete"); - } - if (g.onUploadSuccess) { - g.onUploadSuccess.call(this, f, h, d); - } - } - }; - c.fn.uploadify = function (d) { - if (b[d]) { - return b[d].apply(this, Array.prototype.slice.call(arguments, 1)); - } else { - if (typeof d === "object" || !d) { - return b.init.apply(this, arguments); - } else { - c.error("The method " + d + " does not exist in $.uploadify"); - } - } - }; +/* +Uploadify v3.1.1 +Copyright (c) 2012 Reactive Apps, Ronnie Garcia +Released under the MIT License + +SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com +mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ +SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: +http://www.opensource.org/licenses/mit-license.php +SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: +http://www.opensource.org/licenses/mit-license.php + +SWFObject v2.2 +is released under the MIT License +*/ +; +var swfobject = function () { + var aq = "undefined", + aD = "object", + ab = "Shockwave Flash", + X = "ShockwaveFlash.ShockwaveFlash", + aE = "application/x-shockwave-flash", + ac = "SWFObjectExprInst", + ax = "onreadystatechange", + af = window, + aL = document, + aB = navigator, + aa = false, + Z = [aN], + aG = [], + ag = [], + al = [], + aJ, ad, ap, at, ak = false, + aU = false, + aH, an, aI = true, + ah = function () { + var a = typeof aL.getElementById != aq && typeof aL.getElementsByTagName != aq && typeof aL.createElement != aq, + e = aB.userAgent.toLowerCase(), + c = aB.platform.toLowerCase(), + h = c ? /win/.test(c) : /win/.test(e), + j = c ? /mac/.test(c) : /mac/.test(e), + g = /webkit/.test(e) ? parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, + d = !+"\v1", + f = [0, 0, 0], + k = null; + if (typeof aB.plugins != aq && typeof aB.plugins[ab] == aD) { + k = aB.plugins[ab].description; + if (k && !(typeof aB.mimeTypes != aq && aB.mimeTypes[aE] && !aB.mimeTypes[aE].enabledPlugin)) { + aa = true; + d = false; + k = k.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); + f[0] = parseInt(k.replace(/^(.*)\..*$/, "$1"), 10); + f[1] = parseInt(k.replace(/^.*\.(.*)\s.*$/, "$1"), 10); + f[2] = /[a-zA-Z]/.test(k) ? parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; + } + } else { + if (typeof af.ActiveXObject != aq) { + try { + var i = new ActiveXObject(X); + if (i) { + k = i.GetVariable("$version"); + if (k) { + d = true; + k = k.split(" ")[1].split(","); + f = [parseInt(k[0], 10), parseInt(k[1], 10), parseInt(k[2], 10)]; + } + } + } catch (b) {} + } + } + return { + w3: a, + pv: f, + wk: g, + ie: d, + win: h, + mac: j + }; + }(), + aK = function () { + if (!ah.w3) { + return; + } + if ((typeof aL.readyState != aq && aL.readyState == "complete") || (typeof aL.readyState == aq && (aL.getElementsByTagName("body")[0] || aL.body))) { + aP(); + } + if (!ak) { + if (typeof aL.addEventListener != aq) { + aL.addEventListener("DOMContentLoaded", aP, false); + } + if (ah.ie && ah.win) { + aL.attachEvent(ax, function () { + if (aL.readyState == "complete") { + aL.detachEvent(ax, arguments.callee); + aP(); + } + }); + if (af == top) { + (function () { + if (ak) { + return; + } + try { + aL.documentElement.doScroll("left"); + } catch (a) { + setTimeout(arguments.callee, 0); + return; + } + aP(); + })(); + } + } + if (ah.wk) { + (function () { + if (ak) { + return; + } + if (!/loaded|complete/.test(aL.readyState)) { + setTimeout(arguments.callee, 0); + return; + } + aP(); + })(); + } + aC(aP); + } + }(); + + function aP() { + if (ak) { + return; + } + try { + var b = aL.getElementsByTagName("body")[0].appendChild(ar("span")); + b.parentNode.removeChild(b); + } catch (a) { + return; + } + ak = true; + var d = Z.length; + for (var c = 0; c < d; c++) { + Z[c](); + } + } + function aj(a) { + if (ak) { + a(); + } else { + Z[Z.length] = a; + } + } + function aC(a) { + if (typeof af.addEventListener != aq) { + af.addEventListener("load", a, false); + } else { + if (typeof aL.addEventListener != aq) { + aL.addEventListener("load", a, false); + } else { + if (typeof af.attachEvent != aq) { + aM(af, "onload", a); + } else { + if (typeof af.onload == "function") { + var b = af.onload; + af.onload = function () { + b(); + a(); + }; + } else { + af.onload = a; + } + } + } + } + } + function aN() { + if (aa) { + Y(); + } else { + am(); + } + } + function Y() { + var d = aL.getElementsByTagName("body")[0]; + var b = ar(aD); + b.setAttribute("type", aE); + var a = d.appendChild(b); + if (a) { + var c = 0; + (function () { + if (typeof a.GetVariable != aq) { + var e = a.GetVariable("$version"); + if (e) { + e = e.split(" ")[1].split(","); + ah.pv = [parseInt(e[0], 10), parseInt(e[1], 10), parseInt(e[2], 10)]; + } + } else { + if (c < 10) { + c++; + setTimeout(arguments.callee, 10); + return; + } + } + d.removeChild(b); + a = null; + am(); + })(); + } else { + am(); + } + } + function am() { + var g = aG.length; + if (g > 0) { + for (var h = 0; h < g; h++) { + var c = aG[h].id; + var l = aG[h].callbackFn; + var a = { + success: false, + id: c + }; + if (ah.pv[0] > 0) { + var i = aS(c); + if (i) { + if (ao(aG[h].swfVersion) && !(ah.wk && ah.wk < 312)) { + ay(c, true); + if (l) { + a.success = true; + a.ref = av(c); + l(a); + } + } else { + if (aG[h].expressInstall && au()) { + var e = {}; + e.data = aG[h].expressInstall; + e.width = i.getAttribute("width") || "0"; + e.height = i.getAttribute("height") || "0"; + if (i.getAttribute("class")) { + e.styleclass = i.getAttribute("class"); + } + if (i.getAttribute("align")) { + e.align = i.getAttribute("align"); + } + var f = {}; + var d = i.getElementsByTagName("param"); + var k = d.length; + for (var j = 0; j < k; j++) { + if (d[j].getAttribute("name").toLowerCase() != "movie") { + f[d[j].getAttribute("name")] = d[j].getAttribute("value"); + } + } + ae(e, f, c, l); + } else { + aF(i); + if (l) { + l(a); + } + } + } + } + } else { + ay(c, true); + if (l) { + var b = av(c); + if (b && typeof b.SetVariable != aq) { + a.success = true; + a.ref = b; + } + l(a); + } + } + } + } + } + function av(b) { + var d = null; + var c = aS(b); + if (c && c.nodeName == "OBJECT") { + if (typeof c.SetVariable != aq) { + d = c; + } else { + var a = c.getElementsByTagName(aD)[0]; + if (a) { + d = a; + } + } + } + return d; + } + function au() { + return !aU && ao("6.0.65") && (ah.win || ah.mac) && !(ah.wk && ah.wk < 312); + } + function ae(f, d, h, e) { + aU = true; + ap = e || null; + at = { + success: false, + id: h + }; + var a = aS(h); + if (a) { + if (a.nodeName == "OBJECT") { + aJ = aO(a); + ad = null; + } else { + aJ = a; + ad = h; + } + f.id = ac; + if (typeof f.width == aq || (!/%$/.test(f.width) && parseInt(f.width, 10) < 310)) { + f.width = "310"; + } + if (typeof f.height == aq || (!/%$/.test(f.height) && parseInt(f.height, 10) < 137)) { + f.height = "137"; + } + aL.title = aL.title.slice(0, 47) + " - Flash Player Installation"; + var b = ah.ie && ah.win ? "ActiveX" : "PlugIn", + c = "MMredirectURL=" + af.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + b + "&MMdoctitle=" + aL.title; + if (typeof d.flashvars != aq) { + d.flashvars += "&" + c; + } else { + d.flashvars = c; + } + if (ah.ie && ah.win && a.readyState != 4) { + var g = ar("div"); + h += "SWFObjectNew"; + g.setAttribute("id", h); + a.parentNode.insertBefore(g, a); + a.style.display = "none"; + (function () { + if (a.readyState == 4) { + a.parentNode.removeChild(a); + } else { + setTimeout(arguments.callee, 10); + } + })(); + } + aA(f, d, h); + } + } + function aF(a) { + if (ah.ie && ah.win && a.readyState != 4) { + var b = ar("div"); + a.parentNode.insertBefore(b, a); + b.parentNode.replaceChild(aO(a), b); + a.style.display = "none"; + (function () { + if (a.readyState == 4) { + a.parentNode.removeChild(a); + } else { + setTimeout(arguments.callee, 10); + } + })(); + } else { + a.parentNode.replaceChild(aO(a), a); + } + } + function aO(b) { + var d = ar("div"); + if (ah.win && ah.ie) { + d.innerHTML = b.innerHTML; + } else { + var e = b.getElementsByTagName(aD)[0]; + if (e) { + var a = e.childNodes; + if (a) { + var f = a.length; + for (var c = 0; c < f; c++) { + if (!(a[c].nodeType == 1 && a[c].nodeName == "PARAM") && !(a[c].nodeType == 8)) { + d.appendChild(a[c].cloneNode(true)); + } + } + } + } + } + return d; + } + function aA(e, g, c) { + var d, a = aS(c); + if (ah.wk && ah.wk < 312) { + return d; + } + if (a) { + if (typeof e.id == aq) { + e.id = c; + } + if (ah.ie && ah.win) { + var f = ""; + for (var i in e) { + if (e[i] != Object.prototype[i]) { + if (i.toLowerCase() == "data") { + g.movie = e[i]; + } else { + if (i.toLowerCase() == "styleclass") { + f += ' class="' + e[i] + '"'; + } else { + if (i.toLowerCase() != "classid") { + f += " " + i + '="' + e[i] + '"'; + } + } + } + } + } + var h = ""; + for (var j in g) { + if (g[j] != Object.prototype[j]) { + h += ''; + } + } + a.outerHTML = '" + h + ""; + ag[ag.length] = e.id; + d = aS(e.id); + } else { + var b = ar(aD); + b.setAttribute("type", aE); + for (var k in e) { + if (e[k] != Object.prototype[k]) { + if (k.toLowerCase() == "styleclass") { + b.setAttribute("class", e[k]); + } else { + if (k.toLowerCase() != "classid") { + b.setAttribute(k, e[k]); + } + } + } + } + for (var l in g) { + if (g[l] != Object.prototype[l] && l.toLowerCase() != "movie") { + aQ(b, l, g[l]); + } + } + a.parentNode.replaceChild(b, a); + d = b; + } + } + return d; + } + function aQ(b, d, c) { + var a = ar("param"); + a.setAttribute("name", d); + a.setAttribute("value", c); + b.appendChild(a); + } + function aw(a) { + var b = aS(a); + if (b && b.nodeName == "OBJECT") { + if (ah.ie && ah.win) { + b.style.display = "none"; + (function () { + if (b.readyState == 4) { + aT(a); + } else { + setTimeout(arguments.callee, 10); + } + })(); + } else { + b.parentNode.removeChild(b); + } + } + } + function aT(a) { + var b = aS(a); + if (b) { + for (var c in b) { + if (typeof b[c] == "function") { + b[c] = null; + } + } + b.parentNode.removeChild(b); + } + } + function aS(a) { + var c = null; + try { + c = aL.getElementById(a); + } catch (b) {} + return c; + } + function ar(a) { + return aL.createElement(a); + } + function aM(a, c, b) { + a.attachEvent(c, b); + al[al.length] = [a, c, b]; + } + function ao(a) { + var b = ah.pv, + c = a.split("."); + c[0] = parseInt(c[0], 10); + c[1] = parseInt(c[1], 10) || 0; + c[2] = parseInt(c[2], 10) || 0; + return (b[0] > c[0] || (b[0] == c[0] && b[1] > c[1]) || (b[0] == c[0] && b[1] == c[1] && b[2] >= c[2])) ? true : false; + } + function az(b, f, a, c) { + if (ah.ie && ah.mac) { + return; + } + var e = aL.getElementsByTagName("head")[0]; + if (!e) { + return; + } + var g = (a && typeof a == "string") ? a : "screen"; + if (c) { + aH = null; + an = null; + } + if (!aH || an != g) { + var d = ar("style"); + d.setAttribute("type", "text/css"); + d.setAttribute("media", g); + aH = e.appendChild(d); + if (ah.ie && ah.win && typeof aL.styleSheets != aq && aL.styleSheets.length > 0) { + aH = aL.styleSheets[aL.styleSheets.length - 1]; + } + an = g; + } + if (ah.ie && ah.win) { + if (aH && typeof aH.addRule == aD) { + aH.addRule(b, f); + } + } else { + if (aH && typeof aL.createTextNode != aq) { + aH.appendChild(aL.createTextNode(b + " {" + f + "}")); + } + } + } + function ay(a, c) { + if (!aI) { + return; + } + var b = c ? "visible" : "hidden"; + if (ak && aS(a)) { + aS(a).style.visibility = b; + } else { + az("#" + a, "visibility:" + b); + } + } + function ai(b) { + var a = /[\\\"<>\.;]/; + var c = a.exec(b) != null; + return c && typeof encodeURIComponent != aq ? encodeURIComponent(b) : b; + } + var aR = function () { + if (ah.ie && ah.win) { + window.attachEvent("onunload", function () { + var a = al.length; + for (var b = 0; b < a; b++) { + al[b][0].detachEvent(al[b][1], al[b][2]); + } + var d = ag.length; + for (var c = 0; c < d; c++) { + aw(ag[c]); + } + for (var e in ah) { + ah[e] = null; + } + ah = null; + for (var f in swfobject) { + swfobject[f] = null; + } + swfobject = null; + }); + } + }(); + return { + registerObject: function (a, e, c, b) { + if (ah.w3 && a && e) { + var d = {}; + d.id = a; + d.swfVersion = e; + d.expressInstall = c; + d.callbackFn = b; + aG[aG.length] = d; + ay(a, false); + } else { + if (b) { + b({ + success: false, + id: a + }); + } + } + }, + getObjectById: function (a) { + if (ah.w3) { + return av(a); + } + }, + embedSWF: function (k, e, h, f, c, a, b, i, g, j) { + var d = { + success: false, + id: e + }; + if (ah.w3 && !(ah.wk && ah.wk < 312) && k && e && h && f && c) { + ay(e, false); + aj(function () { + h += ""; + f += ""; + var q = {}; + if (g && typeof g === aD) { + for (var o in g) { + q[o] = g[o]; + } + } + q.data = k; + q.width = h; + q.height = f; + var n = {}; + if (i && typeof i === aD) { + for (var p in i) { + n[p] = i[p]; + } + } + if (b && typeof b === aD) { + for (var l in b) { + if (typeof n.flashvars != aq) { + n.flashvars += "&" + l + "=" + b[l]; + } else { + n.flashvars = l + "=" + b[l]; + } + } + } + if (ao(c)) { + var m = aA(q, n, e); + if (q.id == e) { + ay(e, true); + } + d.success = true; + d.ref = m; + } else { + if (a && au()) { + q.data = a; + ae(q, n, e, j); + return; + } else { + ay(e, true); + } + } + if (j) { + j(d); + } + }); + } else { + if (j) { + j(d); + } + } + }, + switchOffAutoHideShow: function () { + aI = false; + }, + ua: ah, + getFlashPlayerVersion: function () { + return { + major: ah.pv[0], + minor: ah.pv[1], + release: ah.pv[2] + }; + }, + hasFlashPlayerVersion: ao, + createSWF: function (a, b, c) { + if (ah.w3) { + return aA(a, b, c); + } else { + return undefined; + } + }, + showExpressInstall: function (b, a, d, c) { + if (ah.w3 && au()) { + ae(b, a, d, c); + } + }, + removeSWF: function (a) { + if (ah.w3) { + aw(a); + } + }, + createCSS: function (b, a, c, d) { + if (ah.w3) { + az(b, a, c, d); + } + }, + addDomLoadEvent: aj, + addLoadEvent: aC, + getQueryParamValue: function (b) { + var a = aL.location.search || aL.location.hash; + if (a) { + if (/\?/.test(a)) { + a = a.split("?")[1]; + } + if (b == null) { + return ai(a); + } + var c = a.split("&"); + for (var d = 0; d < c.length; d++) { + if (c[d].substring(0, c[d].indexOf("=")) == b) { + return ai(c[d].substring((c[d].indexOf("=") + 1))); + } + } + } + return ""; + }, + expressInstallCallback: function () { + if (aU) { + var a = aS(ac); + if (a && aJ) { + a.parentNode.replaceChild(aJ, a); + if (ad) { + ay(ad, true); + if (ah.ie && ah.win) { + aJ.style.display = "block"; + } + } + if (ap) { + ap(at); + } + } + aU = false; + } + } + }; +}(); +var SWFUpload; +if (SWFUpload == undefined) { + SWFUpload = function (b) { + this.initSWFUpload(b); + }; +} +SWFUpload.prototype.initSWFUpload = function (c) { + try { + this.customSettings = {}; + this.settings = c; + this.eventQueue = []; + this.movieName = "SWFUpload_" + SWFUpload.movieCount++; + this.movieElement = null; + SWFUpload.instances[this.movieName] = this; + this.initSettings(); + this.loadFlash(); + this.displayDebugInfo(); + } catch (d) { + delete SWFUpload.instances[this.movieName]; + throw d; + } +}; +SWFUpload.instances = {}; +SWFUpload.movieCount = 0; +SWFUpload.version = "2.2.0 2009-03-25"; +SWFUpload.QUEUE_ERROR = { + QUEUE_LIMIT_EXCEEDED: -100, + FILE_EXCEEDS_SIZE_LIMIT: -110, + ZERO_BYTE_FILE: -120, + INVALID_FILETYPE: -130 +}; +SWFUpload.UPLOAD_ERROR = { + HTTP_ERROR: -200, + MISSING_UPLOAD_URL: -210, + IO_ERROR: -220, + SECURITY_ERROR: -230, + UPLOAD_LIMIT_EXCEEDED: -240, + UPLOAD_FAILED: -250, + SPECIFIED_FILE_ID_NOT_FOUND: -260, + FILE_VALIDATION_FAILED: -270, + FILE_CANCELLED: -280, + UPLOAD_STOPPED: -290 +}; +SWFUpload.FILE_STATUS = { + QUEUED: -1, + IN_PROGRESS: -2, + ERROR: -3, + COMPLETE: -4, + CANCELLED: -5 +}; +SWFUpload.BUTTON_ACTION = { + SELECT_FILE: -100, + SELECT_FILES: -110, + START_UPLOAD: -120 +}; +SWFUpload.CURSOR = { + ARROW: -1, + HAND: -2 +}; +SWFUpload.WINDOW_MODE = { + WINDOW: "window", + TRANSPARENT: "transparent", + OPAQUE: "opaque" +}; +SWFUpload.completeURL = function (e) { + if (typeof(e) !== "string" || e.match(/^https?:\/\//i) || e.match(/^\//)) { + return e; + } + var f = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); + var d = window.location.pathname.lastIndexOf("/"); + if (d <= 0) { + path = "/"; + } else { + path = window.location.pathname.substr(0, d) + "/"; + } + return path + e; +}; +SWFUpload.prototype.initSettings = function () { + this.ensureDefault = function (c, d) { + this.settings[c] = (this.settings[c] == undefined) ? d : this.settings[c]; + }; + this.ensureDefault("upload_url", ""); + this.ensureDefault("preserve_relative_urls", false); + this.ensureDefault("file_post_name", "Filedata"); + this.ensureDefault("post_params", {}); + this.ensureDefault("use_query_string", false); + this.ensureDefault("requeue_on_error", false); + this.ensureDefault("http_success", []); + this.ensureDefault("assume_success_timeout", 0); + this.ensureDefault("file_types", "*.*"); + this.ensureDefault("file_types_description", "All Files"); + this.ensureDefault("file_size_limit", 0); + this.ensureDefault("file_upload_limit", 0); + this.ensureDefault("file_queue_limit", 0); + this.ensureDefault("flash_url", "swfupload.swf"); + this.ensureDefault("prevent_swf_caching", true); + this.ensureDefault("button_image_url", ""); + this.ensureDefault("button_width", 1); + this.ensureDefault("button_height", 1); + this.ensureDefault("button_text", ""); + this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); + this.ensureDefault("button_text_top_padding", 0); + this.ensureDefault("button_text_left_padding", 0); + this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); + this.ensureDefault("button_disabled", false); + this.ensureDefault("button_placeholder_id", ""); + this.ensureDefault("button_placeholder", null); + this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); + this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); + this.ensureDefault("debug", false); + this.settings.debug_enabled = this.settings.debug; + this.settings.return_upload_start_handler = this.returnUploadStart; + this.ensureDefault("swfupload_loaded_handler", null); + this.ensureDefault("file_dialog_start_handler", null); + this.ensureDefault("file_queued_handler", null); + this.ensureDefault("file_queue_error_handler", null); + this.ensureDefault("file_dialog_complete_handler", null); + this.ensureDefault("upload_start_handler", null); + this.ensureDefault("upload_progress_handler", null); + this.ensureDefault("upload_error_handler", null); + this.ensureDefault("upload_success_handler", null); + this.ensureDefault("upload_complete_handler", null); + this.ensureDefault("debug_handler", this.debugMessage); + this.ensureDefault("custom_settings", {}); + this.customSettings = this.settings.custom_settings; + if ( !! this.settings.prevent_swf_caching) { + this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); + } + if (!this.settings.preserve_relative_urls) { + this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); + this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); + } + delete this.ensureDefault; +}; +SWFUpload.prototype.loadFlash = function () { + var d, c; + if (document.getElementById(this.movieName) !== null) { + throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; + } + d = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; + if (d == undefined) { + throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; + } + c = document.createElement("div"); + c.innerHTML = this.getFlashHTML(); + d.parentNode.replaceChild(c.firstChild, d); + if (window[this.movieName] == undefined) { + window[this.movieName] = this.getMovieElement(); + } +}; +SWFUpload.prototype.getFlashHTML = function () { + return ['', '', '', '', '', '', '', ""].join(""); +}; +SWFUpload.prototype.getFlashVars = function () { + var c = this.buildParamString(); + var d = this.settings.http_success.join(","); + return ["movieName=", encodeURIComponent(this.movieName), "&uploadURL=", encodeURIComponent(this.settings.upload_url), "&useQueryString=", encodeURIComponent(this.settings.use_query_string), "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&httpSuccess=", encodeURIComponent(d), "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&params=", encodeURIComponent(c), "&filePostName=", encodeURIComponent(this.settings.file_post_name), "&fileTypes=", encodeURIComponent(this.settings.file_types), "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&buttonWidth=", encodeURIComponent(this.settings.button_width), "&buttonHeight=", encodeURIComponent(this.settings.button_height), "&buttonText=", encodeURIComponent(this.settings.button_text), "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&buttonAction=", encodeURIComponent(this.settings.button_action), "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join(""); +}; +SWFUpload.prototype.getMovieElement = function () { + if (this.movieElement == undefined) { + this.movieElement = document.getElementById(this.movieName); + } + if (this.movieElement === null) { + throw "Could not find Flash element"; + } + return this.movieElement; +}; +SWFUpload.prototype.buildParamString = function () { + var f = this.settings.post_params; + var d = []; + if (typeof(f) === "object") { + for (var e in f) { + if (f.hasOwnProperty(e)) { + d.push(encodeURIComponent(e.toString()) + "=" + encodeURIComponent(f[e].toString())); + } + } + } + return d.join("&"); +}; +SWFUpload.prototype.destroy = function () { + try { + this.cancelUpload(null, false); + var g = null; + g = this.getMovieElement(); + if (g && typeof(g.CallFunction) === "unknown") { + for (var j in g) { + try { + if (typeof(g[j]) === "function") { + g[j] = null; + } + } catch (h) {} + } + try { + g.parentNode.removeChild(g); + } catch (f) {} + } + window[this.movieName] = null; + SWFUpload.instances[this.movieName] = null; + delete SWFUpload.instances[this.movieName]; + this.movieElement = null; + this.settings = null; + this.customSettings = null; + this.eventQueue = null; + this.movieName = null; + return true; + } catch (i) { + return false; + } +}; +SWFUpload.prototype.displayDebugInfo = function () { + this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", "\t", "upload_url: ", this.settings.upload_url, "\n", "\t", "flash_url: ", this.settings.flash_url, "\n", "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", "\t", "http_success: ", this.settings.http_success.join(", "), "\n", "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", "\t", "file_post_name: ", this.settings.file_post_name, "\n", "\t", "post_params: ", this.settings.post_params.toString(), "\n", "\t", "file_types: ", this.settings.file_types, "\n", "\t", "file_types_description: ", this.settings.file_types_description, "\n", "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", "\t", "debug: ", this.settings.debug.toString(), "\n", "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", "\t", "button_width: ", this.settings.button_width.toString(), "\n", "\t", "button_height: ", this.settings.button_height.toString(), "\n", "\t", "button_text: ", this.settings.button_text.toString(), "\n", "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", "\t", "button_action: ", this.settings.button_action.toString(), "\n", "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"].join("")); +}; +SWFUpload.prototype.addSetting = function (d, f, e) { + if (f == undefined) { + return (this.settings[d] = e); + } else { + return (this.settings[d] = f); + } +}; +SWFUpload.prototype.getSetting = function (b) { + if (this.settings[b] != undefined) { + return this.settings[b]; + } + return ""; +}; +SWFUpload.prototype.callFlash = function (functionName, argumentArray) { + argumentArray = argumentArray || []; + var movieElement = this.getMovieElement(); + var returnValue, returnString; + try { + returnString = movieElement.CallFunction('' + __flash__argumentsToXML(argumentArray, 0) + ""); + returnValue = eval(returnString); + } catch (ex) { + throw "Call to " + functionName + " failed"; + } + if (returnValue != undefined && typeof returnValue.post === "object") { + returnValue = this.unescapeFilePostParams(returnValue); + } + return returnValue; +}; +SWFUpload.prototype.selectFile = function () { + this.callFlash("SelectFile"); +}; +SWFUpload.prototype.selectFiles = function () { + this.callFlash("SelectFiles"); +}; +SWFUpload.prototype.startUpload = function (b) { + this.callFlash("StartUpload", [b]); +}; +SWFUpload.prototype.cancelUpload = function (d, c) { + if (c !== false) { + c = true; + } + this.callFlash("CancelUpload", [d, c]); +}; +SWFUpload.prototype.stopUpload = function () { + this.callFlash("StopUpload"); +}; +SWFUpload.prototype.getStats = function () { + return this.callFlash("GetStats"); +}; +SWFUpload.prototype.setStats = function (b) { + this.callFlash("SetStats", [b]); +}; +SWFUpload.prototype.getFile = function (b) { + if (typeof(b) === "number") { + return this.callFlash("GetFileByIndex", [b]); + } else { + return this.callFlash("GetFile", [b]); + } +}; +SWFUpload.prototype.addFileParam = function (e, d, f) { + return this.callFlash("AddFileParam", [e, d, f]); +}; +SWFUpload.prototype.removeFileParam = function (d, c) { + this.callFlash("RemoveFileParam", [d, c]); +}; +SWFUpload.prototype.setUploadURL = function (b) { + this.settings.upload_url = b.toString(); + this.callFlash("SetUploadURL", [b]); +}; +SWFUpload.prototype.setPostParams = function (b) { + this.settings.post_params = b; + this.callFlash("SetPostParams", [b]); +}; +SWFUpload.prototype.addPostParam = function (d, c) { + this.settings.post_params[d] = c; + this.callFlash("SetPostParams", [this.settings.post_params]); +}; +SWFUpload.prototype.removePostParam = function (b) { + delete this.settings.post_params[b]; + this.callFlash("SetPostParams", [this.settings.post_params]); +}; +SWFUpload.prototype.setFileTypes = function (d, c) { + this.settings.file_types = d; + this.settings.file_types_description = c; + this.callFlash("SetFileTypes", [d, c]); +}; +SWFUpload.prototype.setFileSizeLimit = function (b) { + this.settings.file_size_limit = b; + this.callFlash("SetFileSizeLimit", [b]); +}; +SWFUpload.prototype.setFileUploadLimit = function (b) { + this.settings.file_upload_limit = b; + this.callFlash("SetFileUploadLimit", [b]); +}; +SWFUpload.prototype.setFileQueueLimit = function (b) { + this.settings.file_queue_limit = b; + this.callFlash("SetFileQueueLimit", [b]); +}; +SWFUpload.prototype.setFilePostName = function (b) { + this.settings.file_post_name = b; + this.callFlash("SetFilePostName", [b]); +}; +SWFUpload.prototype.setUseQueryString = function (b) { + this.settings.use_query_string = b; + this.callFlash("SetUseQueryString", [b]); +}; +SWFUpload.prototype.setRequeueOnError = function (b) { + this.settings.requeue_on_error = b; + this.callFlash("SetRequeueOnError", [b]); +}; +SWFUpload.prototype.setHTTPSuccess = function (b) { + if (typeof b === "string") { + b = b.replace(" ", "").split(","); + } + this.settings.http_success = b; + this.callFlash("SetHTTPSuccess", [b]); +}; +SWFUpload.prototype.setAssumeSuccessTimeout = function (b) { + this.settings.assume_success_timeout = b; + this.callFlash("SetAssumeSuccessTimeout", [b]); +}; +SWFUpload.prototype.setDebugEnabled = function (b) { + this.settings.debug_enabled = b; + this.callFlash("SetDebugEnabled", [b]); +}; +SWFUpload.prototype.setButtonImageURL = function (b) { + if (b == undefined) { + b = ""; + } + this.settings.button_image_url = b; + this.callFlash("SetButtonImageURL", [b]); +}; +SWFUpload.prototype.setButtonDimensions = function (f, e) { + this.settings.button_width = f; + this.settings.button_height = e; + var d = this.getMovieElement(); + if (d != undefined) { + d.style.width = f + "px"; + d.style.height = e + "px"; + } + this.callFlash("SetButtonDimensions", [f, e]); +}; +SWFUpload.prototype.setButtonText = function (b) { + this.settings.button_text = b; + this.callFlash("SetButtonText", [b]); +}; +SWFUpload.prototype.setButtonTextPadding = function (c, d) { + this.settings.button_text_top_padding = d; + this.settings.button_text_left_padding = c; + this.callFlash("SetButtonTextPadding", [c, d]); +}; +SWFUpload.prototype.setButtonTextStyle = function (b) { + this.settings.button_text_style = b; + this.callFlash("SetButtonTextStyle", [b]); +}; +SWFUpload.prototype.setButtonDisabled = function (b) { + this.settings.button_disabled = b; + this.callFlash("SetButtonDisabled", [b]); +}; +SWFUpload.prototype.setButtonAction = function (b) { + this.settings.button_action = b; + this.callFlash("SetButtonAction", [b]); +}; +SWFUpload.prototype.setButtonCursor = function (b) { + this.settings.button_cursor = b; + this.callFlash("SetButtonCursor", [b]); +}; +SWFUpload.prototype.queueEvent = function (d, f) { + if (f == undefined) { + f = []; + } else { + if (!(f instanceof Array)) { + f = [f]; + } + } + var e = this; + if (typeof this.settings[d] === "function") { + this.eventQueue.push(function () { + this.settings[d].apply(this, f); + }); + setTimeout(function () { + e.executeNextEvent(); + }, 0); + } else { + if (this.settings[d] !== null) { + throw "Event handler " + d + " is unknown or is not a function"; + } + } +}; +SWFUpload.prototype.executeNextEvent = function () { + var b = this.eventQueue ? this.eventQueue.shift() : null; + if (typeof(b) === "function") { + b.apply(this); + } +}; +SWFUpload.prototype.unescapeFilePostParams = function (l) { + var j = /[$]([0-9a-f]{4})/i; + var i = {}; + var k; + if (l != undefined) { + for (var h in l.post) { + if (l.post.hasOwnProperty(h)) { + k = h; + var g; + while ((g = j.exec(k)) !== null) { + k = k.replace(g[0], String.fromCharCode(parseInt("0x" + g[1], 16))); + } + i[k] = l.post[h]; + } + } + l.post = i; + } + return l; +}; +SWFUpload.prototype.testExternalInterface = function () { + try { + return this.callFlash("TestExternalInterface"); + } catch (b) { + return false; + } +}; +SWFUpload.prototype.flashReady = function () { + var b = this.getMovieElement(); + if (!b) { + this.debug("Flash called back ready but the flash movie can't be found."); + return; + } + this.cleanUp(b); + this.queueEvent("swfupload_loaded_handler"); +}; +SWFUpload.prototype.cleanUp = function (f) { + try { + if (this.movieElement && typeof(f.CallFunction) === "unknown") { + this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); + for (var h in f) { + try { + if (typeof(f[h]) === "function") { + f[h] = null; + } + } catch (e) {} + } + } + } catch (g) {} + window.__flash__removeCallback = function (c, b) { + try { + if (c) { + c[b] = null; + } + } catch (a) {} + }; +}; +SWFUpload.prototype.fileDialogStart = function () { + this.queueEvent("file_dialog_start_handler"); +}; +SWFUpload.prototype.fileQueued = function (b) { + b = this.unescapeFilePostParams(b); + this.queueEvent("file_queued_handler", b); +}; +SWFUpload.prototype.fileQueueError = function (e, f, d) { + e = this.unescapeFilePostParams(e); + this.queueEvent("file_queue_error_handler", [e, f, d]); +}; +SWFUpload.prototype.fileDialogComplete = function (d, f, e) { + this.queueEvent("file_dialog_complete_handler", [d, f, e]); +}; +SWFUpload.prototype.uploadStart = function (b) { + b = this.unescapeFilePostParams(b); + this.queueEvent("return_upload_start_handler", b); +}; +SWFUpload.prototype.returnUploadStart = function (d) { + var c; + if (typeof this.settings.upload_start_handler === "function") { + d = this.unescapeFilePostParams(d); + c = this.settings.upload_start_handler.call(this, d); + } else { + if (this.settings.upload_start_handler != undefined) { + throw "upload_start_handler must be a function"; + } + } + if (c === undefined) { + c = true; + } + c = !! c; + this.callFlash("ReturnUploadStart", [c]); +}; +SWFUpload.prototype.uploadProgress = function (e, f, d) { + e = this.unescapeFilePostParams(e); + this.queueEvent("upload_progress_handler", [e, f, d]); +}; +SWFUpload.prototype.uploadError = function (e, f, d) { + e = this.unescapeFilePostParams(e); + this.queueEvent("upload_error_handler", [e, f, d]); +}; +SWFUpload.prototype.uploadSuccess = function (d, e, f) { + d = this.unescapeFilePostParams(d); + this.queueEvent("upload_success_handler", [d, e, f]); +}; +SWFUpload.prototype.uploadComplete = function (b) { + b = this.unescapeFilePostParams(b); + this.queueEvent("upload_complete_handler", b); +}; +SWFUpload.prototype.debug = function (b) { + this.queueEvent("debug_handler", b); +}; +SWFUpload.prototype.debugMessage = function (h) { + if (this.settings.debug) { + var f, g = []; + if (typeof h === "object" && typeof h.name === "string" && typeof h.message === "string") { + for (var e in h) { + if (h.hasOwnProperty(e)) { + g.push(e + ": " + h[e]); + } + } + f = g.join("\n") || ""; + g = f.split("\n"); + f = "EXCEPTION: " + g.join("\nEXCEPTION: "); + SWFUpload.Console.writeLine(f); + } else { + SWFUpload.Console.writeLine(h); + } + } +}; +SWFUpload.Console = {}; +SWFUpload.Console.writeLine = function (g) { + var e, f; + try { + e = document.getElementById("SWFUpload_Console"); + if (!e) { + f = document.createElement("form"); + document.getElementsByTagName("body")[0].appendChild(f); + e = document.createElement("textarea"); + e.id = "SWFUpload_Console"; + e.style.fontFamily = "monospace"; + e.setAttribute("wrap", "off"); + e.wrap = "off"; + e.style.overflow = "auto"; + e.style.width = "700px"; + e.style.height = "350px"; + e.style.margin = "5px"; + f.appendChild(e); + } + e.value += g + "\n"; + e.scrollTop = e.scrollHeight - e.clientHeight; + } catch (h) { + alert("Exception: " + h.name + " Message: " + h.message); + } +}; +(function (c) { + var b = { + init: function (d, e) { + return this.each(function () { + var n = c(this); + var m = n.clone(); + var j = c.extend({ + id: n.attr("id"), + swf: "uploadify.swf", + uploader: "uploadify.php", + auto: true, + buttonClass: "", + buttonCursor: "hand", + buttonImage: null, + buttonText: "SELECT FILES", + checkExisting: false, + debug: false, + fileObjName: "Filedata", + fileSizeLimit: 0, + fileTypeDesc: "All Files", + fileTypeExts: "*.*", + height: 30, + method: "post", + multi: true, + formData: {}, + preventCaching: true, + progressData: "percentage", + queueID: false, + queueSizeLimit: 999, + removeCompleted: true, + removeTimeout: 3, + requeueErrors: false, + successTimeout: 30, + uploadLimit: 0, + width: 120, + overrideEvents: [] + }, d); + var g = { + assume_success_timeout: j.successTimeout, + button_placeholder_id: j.id, + button_width: j.width, + button_height: j.height, + button_text: null, + button_text_style: null, + button_text_top_padding: 0, + button_text_left_padding: 0, + button_action: (j.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE), + button_disabled: false, + button_cursor: (j.buttonCursor == "arrow" ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND), + button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, + debug: j.debug, + requeue_on_error: j.requeueErrors, + file_post_name: j.fileObjName, + file_size_limit: j.fileSizeLimit, + file_types: j.fileTypeExts, + file_types_description: j.fileTypeDesc, + file_queue_limit: j.queueSizeLimit, + file_upload_limit: j.uploadLimit, + flash_url: j.swf, + prevent_swf_caching: j.preventCaching, + post_params: j.formData, + upload_url: j.uploader, + use_query_string: (j.method == "get"), + file_dialog_complete_handler: a.onDialogClose, + file_dialog_start_handler: a.onDialogOpen, + file_queued_handler: a.onSelect, + file_queue_error_handler: a.onSelectError, + swfupload_loaded_handler: j.onSWFReady, + upload_complete_handler: a.onUploadComplete, + upload_error_handler: a.onUploadError, + upload_progress_handler: a.onUploadProgress, + upload_start_handler: a.onUploadStart, + upload_success_handler: a.onUploadSuccess + }; + if (e) { + g = c.extend(g, e); + } + g = c.extend(g, j); + var o = swfobject.getFlashPlayerVersion(); + var h = (o.major >= 9); + if (h) { + window["uploadify_" + j.id] = new SWFUpload(g); + var i = window["uploadify_" + j.id]; + n.data("uploadify", i); + var l = c("
", { + id: j.id, + "class": "uploadify", + css: { + height: j.height + "px", + width: j.width + "px" + } + }); + c("#" + i.movieName).wrap(l); + l = c("#" + j.id); + l.data("uploadify", i); + var f = c("
", { + id: j.id + "-button", + "class": "uploadify-button " + j.buttonClass + }); + if (j.buttonImage) { + f.css({ + "background-image": "url('" + j.buttonImage + "')", + "text-indent": "-9999px" + }); + } + f.html('' + j.buttonText + "").css({ + height: j.height + "px", + "line-height": j.height + "px", + width: j.width + "px" + }); + l.append(f); + c("#" + i.movieName).css({ + position: "absolute", + "z-index": 1 + }); + if (!j.queueID) { + var k = c("
", { + id: j.id + "-queue", + "class": "uploadify-queue" + }); + l.after(k); + i.settings.queueID = j.id + "-queue"; + i.settings.defaultQueue = true; + } + i.queueData = { + files: {}, + filesSelected: 0, + filesQueued: 0, + filesReplaced: 0, + filesCancelled: 0, + filesErrored: 0, + uploadsSuccessful: 0, + uploadsErrored: 0, + averageSpeed: 0, + queueLength: 0, + queueSize: 0, + uploadSize: 0, + queueBytesUploaded: 0, + uploadQueue: [], + errorMsg: "Some files were not added to the queue:" + }; + i.original = m; + i.wrapper = l; + i.button = f; + i.queue = k; + if (j.onInit) { + j.onInit.call(n, i); + } + } else { + if (j.onFallback) { + j.onFallback.call(n); + } + } + }); + }, + cancel: function (d, f) { + var e = arguments; + this.each(function () { + var l = c(this), + i = l.data("uploadify"), + j = i.settings, + h = -1; + if (e[0]) { + if (e[0] == "*") { + var g = i.queueData.queueLength; + c("#" + j.queueID).find(".uploadify-queue-item").each(function () { + h++; + if (e[1] === true) { + i.cancelUpload(c(this).attr("id"), false); + } else { + i.cancelUpload(c(this).attr("id")); + } + c(this).find(".data").removeClass("data").html(" - Cancelled"); + c(this).find(".uploadify-progress-bar").remove(); + c(this).delay(1000 + 100 * h).fadeOut(500, function () { + c(this).remove(); + }); + }); + i.queueData.queueSize = 0; + i.queueData.queueLength = 0; + if (j.onClearQueue) { + j.onClearQueue.call(l, g); + } + } else { + for (var m = 0; m < e.length; m++) { + i.cancelUpload(e[m]); + c("#" + e[m]).find(".data").removeClass("data").html(" - Cancelled"); + c("#" + e[m]).find(".uploadify-progress-bar").remove(); + c("#" + e[m]).delay(1000 + 100 * m).fadeOut(500, function () { + c(this).remove(); + }); + } + } + } else { + var k = c("#" + j.queueID).find(".uploadify-queue-item").get(0); + $item = c(k); + i.cancelUpload($item.attr("id")); + $item.find(".data").removeClass("data").html(" - Cancelled"); + $item.find(".uploadify-progress-bar").remove(); + $item.delay(1000).fadeOut(500, function () { + c(this).remove(); + }); + } + }); + }, + destroy: function () { + this.each(function () { + var f = c(this), + d = f.data("uploadify"), + e = d.settings; + d.destroy(); + if (e.defaultQueue) { + c("#" + e.queueID).remove(); + } + c("#" + e.id).replaceWith(d.original); + if (e.onDestroy) { + e.onDestroy.call(this); + } + delete d; + }); + }, + disable: function (d) { + this.each(function () { + var g = c(this), + e = g.data("uploadify"), + f = e.settings; + if (d) { + e.button.addClass("disabled"); + if (f.onDisable) { + f.onDisable.call(this); + } + } else { + e.button.removeClass("disabled"); + if (f.onEnable) { + f.onEnable.call(this); + } + } + e.setButtonDisabled(d); + }); + }, + settings: function (e, g, h) { + var d = arguments; + var f = g; + this.each(function () { + var k = c(this), + i = k.data("uploadify"), + j = i.settings; + if (typeof(d[0]) == "object") { + for (var l in g) { + setData(l, g[l]); + } + } + if (d.length === 1) { + f = j[e]; + } else { + switch (e) { + case "uploader": + i.setUploadURL(g); + break; + case "formData": + if (!h) { + g = c.extend(j.formData, g); + } + i.setPostParams(j.formData); + break; + case "method": + if (g == "get") { + i.setUseQueryString(true); + } else { + i.setUseQueryString(false); + } + break; + case "fileObjName": + i.setFilePostName(g); + break; + case "fileTypeExts": + i.setFileTypes(g, j.fileTypeDesc); + break; + case "fileTypeDesc": + i.setFileTypes(j.fileTypeExts, g); + break; + case "fileSizeLimit": + i.setFileSizeLimit(g); + break; + case "uploadLimit": + i.setFileUploadLimit(g); + break; + case "queueSizeLimit": + i.setFileQueueLimit(g); + break; + case "buttonImage": + i.button.css("background-image", settingValue); + break; + case "buttonCursor": + if (g == "arrow") { + i.setButtonCursor(SWFUpload.CURSOR.ARROW); + } else { + i.setButtonCursor(SWFUpload.CURSOR.HAND); + } + break; + case "buttonText": + c("#" + j.id + "-button").find(".uploadify-button-text").html(g); + break; + case "width": + i.setButtonDimensions(g, j.height); + break; + case "height": + i.setButtonDimensions(j.width, g); + break; + case "multi": + if (g) { + i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES); + } else { + i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE); + } + break; + } + j[e] = g; + } + }); + if (d.length === 1) { + return f; + } + }, + stop: function () { + this.each(function () { + var e = c(this), + d = e.data("uploadify"); + d.queueData.averageSpeed = 0; + d.queueData.uploadSize = 0; + d.queueData.bytesUploaded = 0; + d.queueData.uploadQueue = []; + d.stopUpload(); + }); + }, + upload: function () { + var d = arguments; + this.each(function () { + var f = c(this), + e = f.data("uploadify"); + e.queueData.averageSpeed = 0; + e.queueData.uploadSize = 0; + e.queueData.bytesUploaded = 0; + e.queueData.uploadQueue = []; + if (d[0]) { + if (d[0] == "*") { + e.queueData.uploadSize = e.queueData.queueSize; + e.queueData.uploadQueue.push("*"); + e.startUpload(); + } else { + for (var g = 0; g < d.length; g++) { + e.queueData.uploadSize += e.queueData.files[d[g]].size; + e.queueData.uploadQueue.push(d[g]); + } + e.startUpload(e.queueData.uploadQueue.shift()); + } + } else { + e.startUpload(); + } + }); + } + }; + var a = { + onDialogOpen: function () { + var d = this.settings; + this.queueData.errorMsg = "Some files were not added to the queue:"; + this.queueData.filesReplaced = 0; + this.queueData.filesCancelled = 0; + if (d.onDialogOpen) { + d.onDialogOpen.call(this); + } + }, + onDialogClose: function (d, f, g) { + var e = this.settings; + this.queueData.filesErrored = d - f; + this.queueData.filesSelected = d; + this.queueData.filesQueued = f - this.queueData.filesCancelled; + this.queueData.queueLength = g; + if (c.inArray("onDialogClose", e.overrideEvents) < 0) { + if (this.queueData.filesErrored > 0) { + alert(this.queueData.errorMsg); + } + } + if (e.onDialogClose) { + e.onDialogClose.call(this, this.queueData); + } + if (e.auto) { + c("#" + e.id).uploadify("upload", "*"); + } + }, + onSelect: function (g) { + var h = this.settings; + var e = {}; + for (var f in this.queueData.files) { + e = this.queueData.files[f]; + if (e.uploaded != true && e.name == g.name) { + var d = confirm('The file named "' + g.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?'); + if (!d) { + this.cancelUpload(g.id); + this.queueData.filesCancelled++; + return false; + } else { + c("#" + e.id).remove(); + this.cancelUpload(e.id); + this.queueData.filesReplaced++; + } + } + } + var i = Math.round(g.size / 1024); + var l = "KB"; + if (i > 1000) { + i = Math.round(i / 1000); + l = "MB"; + } + var k = i.toString().split("."); + i = k[0]; + if (k.length > 1) { + i += "." + k[1].substr(0, 2); + } + i += l; + var j = g.name; + if (j.length > 25) { + j = j.substr(0, 25) + "..."; + } + if (c.inArray("onSelect", h.overrideEvents) < 0) { + c("#" + h.queueID).append('
X
' + j + " (" + i + ')
'); + } + this.queueData.queueSize += g.size; + this.queueData.files[g.id] = g; + if (h.onSelect) { + h.onSelect.apply(this, arguments); + } + }, + onSelectError: function (d, g, f) { + var e = this.settings; + if (c.inArray("onSelectError", e.overrideEvents) < 0) { + switch (g) { + case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: + if (e.queueSizeLimit > f) { + this.queueData.errorMsg += "\nThe number of files selected exceeds the remaining upload limit (" + f + ")."; + } else { + this.queueData.errorMsg += "\nThe number of files selected exceeds the queue size limit (" + e.queueSizeLimit + ")."; + } + break; + case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: + this.queueData.errorMsg += '\nThe file "' + d.name + '" exceeds the size limit (' + e.fileSizeLimit + ")."; + break; + case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: + this.queueData.errorMsg += '\nThe file "' + d.name + '" is empty.'; + break; + case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: + this.queueData.errorMsg += '\nThe file "' + d.name + '" is not an accepted file type (' + e.fileTypeDesc + ")."; + break; + } + } + if (g != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { + delete this.queueData.files[d.id]; + } + if (e.onSelectError) { + e.onSelectError.apply(this, arguments); + } + }, + onQueueComplete: function () { + if (this.settings.onQueueComplete) { + this.settings.onQueueComplete.call(this, this.settings.queueData); + } + }, + onUploadComplete: function (f) { + var g = this.settings, + d = this; + var e = this.getStats(); + this.queueData.queueLength = e.files_queued; + if (this.queueData.uploadQueue[0] == "*") { + if (this.queueData.queueLength > 0) { + this.startUpload(); + } else { + this.queueData.uploadQueue = []; + if (g.onQueueComplete) { + g.onQueueComplete.call(this, this.queueData); + } + } + } else { + if (this.queueData.uploadQueue.length > 0) { + this.startUpload(this.queueData.uploadQueue.shift()); + } else { + this.queueData.uploadQueue = []; + if (g.onQueueComplete) { + g.onQueueComplete.call(this, this.queueData); + } + } + } + if (c.inArray("onUploadComplete", g.overrideEvents) < 0) { + if (g.removeCompleted) { + switch (f.filestatus) { + case SWFUpload.FILE_STATUS.COMPLETE: + setTimeout(function () { + if (c("#" + f.id)) { + d.queueData.queueSize -= f.size; + d.queueData.queueLength -= 1; + delete d.queueData.files[f.id]; + c("#" + f.id).fadeOut(500, function () { + c(this).remove(); + }); + } + }, g.removeTimeout * 1000); + break; + case SWFUpload.FILE_STATUS.ERROR: + if (!g.requeueErrors) { + setTimeout(function () { + if (c("#" + f.id)) { + d.queueData.queueSize -= f.size; + d.queueData.queueLength -= 1; + delete d.queueData.files[f.id]; + c("#" + f.id).fadeOut(500, function () { + c(this).remove(); + }); + } + }, g.removeTimeout * 1000); + } + break; + } + } else { + f.uploaded = true; + } + } + if (g.onUploadComplete) { + g.onUploadComplete.call(this, f); + } + }, + onUploadError: function (e, i, h) { + var f = this.settings; + var g = "Error"; + switch (i) { + case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: + g = "HTTP Error (" + h + ")"; + break; + case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL: + g = "Missing Upload URL"; + break; + case SWFUpload.UPLOAD_ERROR.IO_ERROR: + g = "IO Error"; + break; + case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: + g = "Security Error"; + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: + alert("The upload limit has been reached (" + h + ")."); + g = "Exceeds Upload Limit"; + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: + g = "Failed"; + break; + case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND: + break; + case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: + g = "Validation Error"; + break; + case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: + g = "Cancelled"; + this.queueData.queueSize -= e.size; + this.queueData.queueLength -= 1; + if (e.status == SWFUpload.FILE_STATUS.IN_PROGRESS || c.inArray(e.id, this.queueData.uploadQueue) >= 0) { + this.queueData.uploadSize -= e.size; + } + if (f.onCancel) { + f.onCancel.call(this, e); + } + delete this.queueData.files[e.id]; + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: + g = "Stopped"; + break; + } + if (c.inArray("onUploadError", f.overrideEvents) < 0) { + if (i != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && i != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) { + c("#" + e.id).addClass("uploadify-error"); + } + c("#" + e.id).find(".uploadify-progress-bar").css("width", "1px"); + if (i != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && e.status != SWFUpload.FILE_STATUS.COMPLETE) { + c("#" + e.id).find(".data").html(" - " + g); + } + } + var d = this.getStats(); + this.queueData.uploadsErrored = d.upload_errors; + if (f.onUploadError) { + f.onUploadError.call(this, e, i, h, g); + } + }, + onUploadProgress: function (g, m, j) { + var h = this.settings; + var e = new Date(); + var n = e.getTime(); + var k = n - this.timer; + if (k > 500) { + this.timer = n; + } + var i = m - this.bytesLoaded; + this.bytesLoaded = m; + var d = this.queueData.queueBytesUploaded + m; + var p = Math.round(m / j * 100); + var o = "KB/s"; + var l = 0; + var f = (i / 1024) / (k / 1000); + f = Math.floor(f * 10) / 10; + if (this.queueData.averageSpeed > 0) { + this.queueData.averageSpeed = Math.floor((this.queueData.averageSpeed + f) / 2); + } else { + this.queueData.averageSpeed = Math.floor(f); + } + if (f > 1000) { + l = (f * 0.001); + this.queueData.averageSpeed = Math.floor(l); + o = "MB/s"; + } + if (c.inArray("onUploadProgress", h.overrideEvents) < 0) { + if (h.progressData == "percentage") { + c("#" + g.id).find(".data").html(" - " + p + "%"); + } else { + if (h.progressData == "speed" && k > 500) { + c("#" + g.id).find(".data").html(" - " + this.queueData.averageSpeed + o); + } + } + c("#" + g.id).find(".uploadify-progress-bar").css("width", p + "%"); + } + if (h.onUploadProgress) { + h.onUploadProgress.call(this, g, m, j, d, this.queueData.uploadSize); + } + }, + onUploadStart: function (d) { + var e = this.settings; + var f = new Date(); + this.timer = f.getTime(); + this.bytesLoaded = 0; + if (this.queueData.uploadQueue.length == 0) { + this.queueData.uploadSize = d.size; + } + if (e.checkExisting) { + c.ajax({ + type: "POST", + async: false, + url: e.checkExisting, + data: { + filename: d.name + }, + success: function (h) { + if (h == 1) { + var g = confirm('A file with the name "' + d.name + '" already exists on the server.\nWould you like to replace the existing file?'); + if (!g) { + this.cancelUpload(d.id); + c("#" + d.id).remove(); + if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) { + if (this.queueData.uploadQueue[0] == "*") { + this.startUpload(); + } else { + this.startUpload(this.queueData.uploadQueue.shift()); + } + } + } + } + } + }); + } + if (e.onUploadStart) { + e.onUploadStart.call(this, d); + } + }, + onUploadSuccess: function (f, h, d) { + var g = this.settings; + var e = this.getStats(); + this.queueData.uploadsSuccessful = e.successful_uploads; + this.queueData.queueBytesUploaded += f.size; + if (c.inArray("onUploadSuccess", g.overrideEvents) < 0) { + c("#" + f.id).find(".data").html(" - Complete"); + } + if (g.onUploadSuccess) { + g.onUploadSuccess.call(this, f, h, d); + } + } + }; + c.fn.uploadify = function (d) { + if (b[d]) { + return b[d].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + if (typeof d === "object" || !d) { + return b.init.apply(this, arguments); + } else { + c.error("The method " + d + " does not exist in $.uploadify"); + } + } + }; })($); \ No newline at end of file diff --git a/web/public_php/ams/js/jquery.uploadify-3.1.min.js b/web/public_php/ams/js/jquery.uploadify-3.1.min.js index f475d7c05..2ecda85b0 100644 --- a/web/public_php/ams/js/jquery.uploadify-3.1.min.js +++ b/web/public_php/ams/js/jquery.uploadify-3.1.min.js @@ -1,16 +1,16 @@ -/* -Uploadify v3.1.1 -Copyright (c) 2012 Reactive Apps, Ronnie Garcia -Released under the MIT License - -SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com -mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ -SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: -http://www.opensource.org/licenses/mit-license.php -SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: -http://www.opensource.org/licenses/mit-license.php - -SWFObject v2.2 -is released under the MIT License -*/ +/* +Uploadify v3.1.1 +Copyright (c) 2012 Reactive Apps, Ronnie Garcia +Released under the MIT License + +SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com +mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ +SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: +http://www.opensource.org/licenses/mit-license.php +SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: +http://www.opensource.org/licenses/mit-license.php + +SWFObject v2.2 +is released under the MIT License +*/ ;var swfobject=function(){var aq="undefined",aD="object",ab="Shockwave Flash",X="ShockwaveFlash.ShockwaveFlash",aE="application/x-shockwave-flash",ac="SWFObjectExprInst",ax="onreadystatechange",af=window,aL=document,aB=navigator,aa=false,Z=[aN],aG=[],ag=[],al=[],aJ,ad,ap,at,ak=false,aU=false,aH,an,aI=true,ah=function(){var a=typeof aL.getElementById!=aq&&typeof aL.getElementsByTagName!=aq&&typeof aL.createElement!=aq,e=aB.userAgent.toLowerCase(),c=aB.platform.toLowerCase(),h=c?/win/.test(c):/win/.test(e),j=c?/mac/.test(c):/mac/.test(e),g=/webkit/.test(e)?parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,d=!+"\v1",f=[0,0,0],k=null;if(typeof aB.plugins!=aq&&typeof aB.plugins[ab]==aD){k=aB.plugins[ab].description;if(k&&!(typeof aB.mimeTypes!=aq&&aB.mimeTypes[aE]&&!aB.mimeTypes[aE].enabledPlugin)){aa=true;d=false;k=k.replace(/^.*\s+(\S+\s+\S+$)/,"$1");f[0]=parseInt(k.replace(/^(.*)\..*$/,"$1"),10);f[1]=parseInt(k.replace(/^.*\.(.*)\s.*$/,"$1"),10);f[2]=/[a-zA-Z]/.test(k)?parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0;}}else{if(typeof af.ActiveXObject!=aq){try{var i=new ActiveXObject(X);if(i){k=i.GetVariable("$version");if(k){d=true;k=k.split(" ")[1].split(",");f=[parseInt(k[0],10),parseInt(k[1],10),parseInt(k[2],10)];}}}catch(b){}}}return{w3:a,pv:f,wk:g,ie:d,win:h,mac:j};}(),aK=function(){if(!ah.w3){return;}if((typeof aL.readyState!=aq&&aL.readyState=="complete")||(typeof aL.readyState==aq&&(aL.getElementsByTagName("body")[0]||aL.body))){aP();}if(!ak){if(typeof aL.addEventListener!=aq){aL.addEventListener("DOMContentLoaded",aP,false);}if(ah.ie&&ah.win){aL.attachEvent(ax,function(){if(aL.readyState=="complete"){aL.detachEvent(ax,arguments.callee);aP();}});if(af==top){(function(){if(ak){return;}try{aL.documentElement.doScroll("left");}catch(a){setTimeout(arguments.callee,0);return;}aP();})();}}if(ah.wk){(function(){if(ak){return;}if(!/loaded|complete/.test(aL.readyState)){setTimeout(arguments.callee,0);return;}aP();})();}aC(aP);}}();function aP(){if(ak){return;}try{var b=aL.getElementsByTagName("body")[0].appendChild(ar("span"));b.parentNode.removeChild(b);}catch(a){return;}ak=true;var d=Z.length;for(var c=0;c0){for(var h=0;h0){var i=aS(c);if(i){if(ao(aG[h].swfVersion)&&!(ah.wk&&ah.wk<312)){ay(c,true);if(l){a.success=true;a.ref=av(c);l(a);}}else{if(aG[h].expressInstall&&au()){var e={};e.data=aG[h].expressInstall;e.width=i.getAttribute("width")||"0";e.height=i.getAttribute("height")||"0";if(i.getAttribute("class")){e.styleclass=i.getAttribute("class");}if(i.getAttribute("align")){e.align=i.getAttribute("align");}var f={};var d=i.getElementsByTagName("param");var k=d.length;for(var j=0;j';}}a.outerHTML='"+h+"";ag[ag.length]=e.id;d=aS(e.id);}else{var b=ar(aD);b.setAttribute("type",aE);for(var k in e){if(e[k]!=Object.prototype[k]){if(k.toLowerCase()=="styleclass"){b.setAttribute("class",e[k]);}else{if(k.toLowerCase()!="classid"){b.setAttribute(k,e[k]);}}}}for(var l in g){if(g[l]!=Object.prototype[l]&&l.toLowerCase()!="movie"){aQ(b,l,g[l]);}}a.parentNode.replaceChild(b,a);d=b;}}return d;}function aQ(b,d,c){var a=ar("param");a.setAttribute("name",d);a.setAttribute("value",c);b.appendChild(a);}function aw(a){var b=aS(a);if(b&&b.nodeName=="OBJECT"){if(ah.ie&&ah.win){b.style.display="none";(function(){if(b.readyState==4){aT(a);}else{setTimeout(arguments.callee,10);}})();}else{b.parentNode.removeChild(b);}}}function aT(a){var b=aS(a);if(b){for(var c in b){if(typeof b[c]=="function"){b[c]=null;}}b.parentNode.removeChild(b);}}function aS(a){var c=null;try{c=aL.getElementById(a);}catch(b){}return c;}function ar(a){return aL.createElement(a);}function aM(a,c,b){a.attachEvent(c,b);al[al.length]=[a,c,b];}function ao(a){var b=ah.pv,c=a.split(".");c[0]=parseInt(c[0],10);c[1]=parseInt(c[1],10)||0;c[2]=parseInt(c[2],10)||0;return(b[0]>c[0]||(b[0]==c[0]&&b[1]>c[1])||(b[0]==c[0]&&b[1]==c[1]&&b[2]>=c[2]))?true:false;}function az(b,f,a,c){if(ah.ie&&ah.mac){return;}var e=aL.getElementsByTagName("head")[0];if(!e){return;}var g=(a&&typeof a=="string")?a:"screen";if(c){aH=null;an=null;}if(!aH||an!=g){var d=ar("style");d.setAttribute("type","text/css");d.setAttribute("media",g);aH=e.appendChild(d);if(ah.ie&&ah.win&&typeof aL.styleSheets!=aq&&aL.styleSheets.length>0){aH=aL.styleSheets[aL.styleSheets.length-1];}an=g;}if(ah.ie&&ah.win){if(aH&&typeof aH.addRule==aD){aH.addRule(b,f);}}else{if(aH&&typeof aL.createTextNode!=aq){aH.appendChild(aL.createTextNode(b+" {"+f+"}"));}}}function ay(a,c){if(!aI){return;}var b=c?"visible":"hidden";if(ak&&aS(a)){aS(a).style.visibility=b;}else{az("#"+a,"visibility:"+b);}}function ai(b){var a=/[\\\"<>\.;]/;var c=a.exec(b)!=null;return c&&typeof encodeURIComponent!=aq?encodeURIComponent(b):b;}var aR=function(){if(ah.ie&&ah.win){window.attachEvent("onunload",function(){var a=al.length;for(var b=0;b','','','','','','',""].join("");};SWFUpload.prototype.getFlashVars=function(){var c=this.buildParamString();var d=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&uploadURL=",encodeURIComponent(this.settings.upload_url),"&useQueryString=",encodeURIComponent(this.settings.use_query_string),"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&httpSuccess=",encodeURIComponent(d),"&assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&params=",encodeURIComponent(c),"&filePostName=",encodeURIComponent(this.settings.file_post_name),"&fileTypes=",encodeURIComponent(this.settings.file_types),"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&buttonWidth=",encodeURIComponent(this.settings.button_width),"&buttonHeight=",encodeURIComponent(this.settings.button_height),"&buttonText=",encodeURIComponent(this.settings.button_text),"&buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&buttonAction=",encodeURIComponent(this.settings.button_action),"&buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("");};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName);}if(this.movieElement===null){throw"Could not find Flash element";}return this.movieElement;};SWFUpload.prototype.buildParamString=function(){var f=this.settings.post_params;var d=[];if(typeof(f)==="object"){for(var e in f){if(f.hasOwnProperty(e)){d.push(encodeURIComponent(e.toString())+"="+encodeURIComponent(f[e].toString()));}}}return d.join("&");};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var g=null;g=this.getMovieElement();if(g&&typeof(g.CallFunction)==="unknown"){for(var j in g){try{if(typeof(g[j])==="function"){g[j]=null;}}catch(h){}}try{g.parentNode.removeChild(g);}catch(f){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true;}catch(i){return false;}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url: ",this.settings.upload_url,"\n","\t","flash_url: ",this.settings.flash_url,"\n","\t","use_query_string: ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n","\t","http_success: ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout: ",this.settings.assume_success_timeout,"\n","\t","file_post_name: ",this.settings.file_post_name,"\n","\t","post_params: ",this.settings.post_params.toString(),"\n","\t","file_types: ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit: ",this.settings.file_size_limit,"\n","\t","file_upload_limit: ",this.settings.file_upload_limit,"\n","\t","file_queue_limit: ",this.settings.file_queue_limit,"\n","\t","debug: ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder: ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url: ",this.settings.button_image_url.toString(),"\n","\t","button_width: ",this.settings.button_width.toString(),"\n","\t","button_height: ",this.settings.button_height.toString(),"\n","\t","button_text: ",this.settings.button_text.toString(),"\n","\t","button_text_style: ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action: ",this.settings.button_action.toString(),"\n","\t","button_disabled: ",this.settings.button_disabled.toString(),"\n","\t","custom_settings: ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned: ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned: ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned: ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned: ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned: ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned: ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned: ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned: ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned: ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""));};SWFUpload.prototype.addSetting=function(d,f,e){if(f==undefined){return(this.settings[d]=e);}else{return(this.settings[d]=f);}};SWFUpload.prototype.getSetting=function(b){if(this.settings[b]!=undefined){return this.settings[b];}return"";};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction(''+__flash__argumentsToXML(argumentArray,0)+"");returnValue=eval(returnString);}catch(ex){throw"Call to "+functionName+" failed";}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue);}return returnValue;};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile");};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles");};SWFUpload.prototype.startUpload=function(b){this.callFlash("StartUpload",[b]);};SWFUpload.prototype.cancelUpload=function(d,c){if(c!==false){c=true;}this.callFlash("CancelUpload",[d,c]);};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload");};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats");};SWFUpload.prototype.setStats=function(b){this.callFlash("SetStats",[b]);};SWFUpload.prototype.getFile=function(b){if(typeof(b)==="number"){return this.callFlash("GetFileByIndex",[b]);}else{return this.callFlash("GetFile",[b]);}};SWFUpload.prototype.addFileParam=function(e,d,f){return this.callFlash("AddFileParam",[e,d,f]);};SWFUpload.prototype.removeFileParam=function(d,c){this.callFlash("RemoveFileParam",[d,c]);};SWFUpload.prototype.setUploadURL=function(b){this.settings.upload_url=b.toString();this.callFlash("SetUploadURL",[b]);};SWFUpload.prototype.setPostParams=function(b){this.settings.post_params=b;this.callFlash("SetPostParams",[b]);};SWFUpload.prototype.addPostParam=function(d,c){this.settings.post_params[d]=c;this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.removePostParam=function(b){delete this.settings.post_params[b];this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.setFileTypes=function(d,c){this.settings.file_types=d;this.settings.file_types_description=c;this.callFlash("SetFileTypes",[d,c]);};SWFUpload.prototype.setFileSizeLimit=function(b){this.settings.file_size_limit=b;this.callFlash("SetFileSizeLimit",[b]);};SWFUpload.prototype.setFileUploadLimit=function(b){this.settings.file_upload_limit=b;this.callFlash("SetFileUploadLimit",[b]);};SWFUpload.prototype.setFileQueueLimit=function(b){this.settings.file_queue_limit=b;this.callFlash("SetFileQueueLimit",[b]);};SWFUpload.prototype.setFilePostName=function(b){this.settings.file_post_name=b;this.callFlash("SetFilePostName",[b]);};SWFUpload.prototype.setUseQueryString=function(b){this.settings.use_query_string=b;this.callFlash("SetUseQueryString",[b]);};SWFUpload.prototype.setRequeueOnError=function(b){this.settings.requeue_on_error=b;this.callFlash("SetRequeueOnError",[b]);};SWFUpload.prototype.setHTTPSuccess=function(b){if(typeof b==="string"){b=b.replace(" ","").split(",");}this.settings.http_success=b;this.callFlash("SetHTTPSuccess",[b]);};SWFUpload.prototype.setAssumeSuccessTimeout=function(b){this.settings.assume_success_timeout=b;this.callFlash("SetAssumeSuccessTimeout",[b]);};SWFUpload.prototype.setDebugEnabled=function(b){this.settings.debug_enabled=b;this.callFlash("SetDebugEnabled",[b]);};SWFUpload.prototype.setButtonImageURL=function(b){if(b==undefined){b="";}this.settings.button_image_url=b;this.callFlash("SetButtonImageURL",[b]);};SWFUpload.prototype.setButtonDimensions=function(f,e){this.settings.button_width=f;this.settings.button_height=e;var d=this.getMovieElement();if(d!=undefined){d.style.width=f+"px";d.style.height=e+"px";}this.callFlash("SetButtonDimensions",[f,e]);};SWFUpload.prototype.setButtonText=function(b){this.settings.button_text=b;this.callFlash("SetButtonText",[b]);};SWFUpload.prototype.setButtonTextPadding=function(c,d){this.settings.button_text_top_padding=d;this.settings.button_text_left_padding=c;this.callFlash("SetButtonTextPadding",[c,d]);};SWFUpload.prototype.setButtonTextStyle=function(b){this.settings.button_text_style=b;this.callFlash("SetButtonTextStyle",[b]);};SWFUpload.prototype.setButtonDisabled=function(b){this.settings.button_disabled=b;this.callFlash("SetButtonDisabled",[b]);};SWFUpload.prototype.setButtonAction=function(b){this.settings.button_action=b;this.callFlash("SetButtonAction",[b]);};SWFUpload.prototype.setButtonCursor=function(b){this.settings.button_cursor=b;this.callFlash("SetButtonCursor",[b]);};SWFUpload.prototype.queueEvent=function(d,f){if(f==undefined){f=[];}else{if(!(f instanceof Array)){f=[f];}}var e=this;if(typeof this.settings[d]==="function"){this.eventQueue.push(function(){this.settings[d].apply(this,f);});setTimeout(function(){e.executeNextEvent();},0);}else{if(this.settings[d]!==null){throw"Event handler "+d+" is unknown or is not a function";}}};SWFUpload.prototype.executeNextEvent=function(){var b=this.eventQueue?this.eventQueue.shift():null;if(typeof(b)==="function"){b.apply(this);}};SWFUpload.prototype.unescapeFilePostParams=function(l){var j=/[$]([0-9a-f]{4})/i;var i={};var k;if(l!=undefined){for(var h in l.post){if(l.post.hasOwnProperty(h)){k=h;var g;while((g=j.exec(k))!==null){k=k.replace(g[0],String.fromCharCode(parseInt("0x"+g[1],16)));}i[k]=l.post[h];}}l.post=i;}return l;};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface");}catch(b){return false;}};SWFUpload.prototype.flashReady=function(){var b=this.getMovieElement();if(!b){this.debug("Flash called back ready but the flash movie can't be found.");return;}this.cleanUp(b);this.queueEvent("swfupload_loaded_handler");};SWFUpload.prototype.cleanUp=function(f){try{if(this.movieElement&&typeof(f.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var h in f){try{if(typeof(f[h])==="function"){f[h]=null;}}catch(e){}}}}catch(g){}window.__flash__removeCallback=function(c,b){try{if(c){c[b]=null;}}catch(a){}};};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler");};SWFUpload.prototype.fileQueued=function(b){b=this.unescapeFilePostParams(b);this.queueEvent("file_queued_handler",b);};SWFUpload.prototype.fileQueueError=function(e,f,d){e=this.unescapeFilePostParams(e);this.queueEvent("file_queue_error_handler",[e,f,d]);};SWFUpload.prototype.fileDialogComplete=function(d,f,e){this.queueEvent("file_dialog_complete_handler",[d,f,e]);};SWFUpload.prototype.uploadStart=function(b){b=this.unescapeFilePostParams(b);this.queueEvent("return_upload_start_handler",b);};SWFUpload.prototype.returnUploadStart=function(d){var c;if(typeof this.settings.upload_start_handler==="function"){d=this.unescapeFilePostParams(d);c=this.settings.upload_start_handler.call(this,d);}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function";}}if(c===undefined){c=true;}c=!!c;this.callFlash("ReturnUploadStart",[c]);};SWFUpload.prototype.uploadProgress=function(e,f,d){e=this.unescapeFilePostParams(e);this.queueEvent("upload_progress_handler",[e,f,d]);};SWFUpload.prototype.uploadError=function(e,f,d){e=this.unescapeFilePostParams(e);this.queueEvent("upload_error_handler",[e,f,d]);};SWFUpload.prototype.uploadSuccess=function(d,e,f){d=this.unescapeFilePostParams(d);this.queueEvent("upload_success_handler",[d,e,f]);};SWFUpload.prototype.uploadComplete=function(b){b=this.unescapeFilePostParams(b);this.queueEvent("upload_complete_handler",b);};SWFUpload.prototype.debug=function(b){this.queueEvent("debug_handler",b);};SWFUpload.prototype.debugMessage=function(h){if(this.settings.debug){var f,g=[];if(typeof h==="object"&&typeof h.name==="string"&&typeof h.message==="string"){for(var e in h){if(h.hasOwnProperty(e)){g.push(e+": "+h[e]);}}f=g.join("\n")||"";g=f.split("\n");f="EXCEPTION: "+g.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(f);}else{SWFUpload.Console.writeLine(h);}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(g){var e,f;try{e=document.getElementById("SWFUpload_Console");if(!e){f=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(f);e=document.createElement("textarea");e.id="SWFUpload_Console";e.style.fontFamily="monospace";e.setAttribute("wrap","off");e.wrap="off";e.style.overflow="auto";e.style.width="700px";e.style.height="350px";e.style.margin="5px";f.appendChild(e);}e.value+=g+"\n";e.scrollTop=e.scrollHeight-e.clientHeight;}catch(h){alert("Exception: "+h.name+" Message: "+h.message);}};(function(c){var b={init:function(d,e){return this.each(function(){var n=c(this);var m=n.clone();var j=c.extend({id:n.attr("id"),swf:"uploadify.swf",uploader:"uploadify.php",auto:true,buttonClass:"",buttonCursor:"hand",buttonImage:null,buttonText:"SELECT FILES",checkExisting:false,debug:false,fileObjName:"Filedata",fileSizeLimit:0,fileTypeDesc:"All Files",fileTypeExts:"*.*",height:30,method:"post",multi:true,formData:{},preventCaching:true,progressData:"percentage",queueID:false,queueSizeLimit:999,removeCompleted:true,removeTimeout:3,requeueErrors:false,successTimeout:30,uploadLimit:0,width:120,overrideEvents:[]},d);var g={assume_success_timeout:j.successTimeout,button_placeholder_id:j.id,button_width:j.width,button_height:j.height,button_text:null,button_text_style:null,button_text_top_padding:0,button_text_left_padding:0,button_action:(j.multi?SWFUpload.BUTTON_ACTION.SELECT_FILES:SWFUpload.BUTTON_ACTION.SELECT_FILE),button_disabled:false,button_cursor:(j.buttonCursor=="arrow"?SWFUpload.CURSOR.ARROW:SWFUpload.CURSOR.HAND),button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,debug:j.debug,requeue_on_error:j.requeueErrors,file_post_name:j.fileObjName,file_size_limit:j.fileSizeLimit,file_types:j.fileTypeExts,file_types_description:j.fileTypeDesc,file_queue_limit:j.queueSizeLimit,file_upload_limit:j.uploadLimit,flash_url:j.swf,prevent_swf_caching:j.preventCaching,post_params:j.formData,upload_url:j.uploader,use_query_string:(j.method=="get"),file_dialog_complete_handler:a.onDialogClose,file_dialog_start_handler:a.onDialogOpen,file_queued_handler:a.onSelect,file_queue_error_handler:a.onSelectError,swfupload_loaded_handler:j.onSWFReady,upload_complete_handler:a.onUploadComplete,upload_error_handler:a.onUploadError,upload_progress_handler:a.onUploadProgress,upload_start_handler:a.onUploadStart,upload_success_handler:a.onUploadSuccess};if(e){g=c.extend(g,e);}g=c.extend(g,j);var o=swfobject.getFlashPlayerVersion();var h=(o.major>=9);if(h){window["uploadify_"+j.id]=new SWFUpload(g);var i=window["uploadify_"+j.id];n.data("uploadify",i);var l=c("
",{id:j.id,"class":"uploadify",css:{height:j.height+"px",width:j.width+"px"}});c("#"+i.movieName).wrap(l);l=c("#"+j.id);l.data("uploadify",i);var f=c("
",{id:j.id+"-button","class":"uploadify-button "+j.buttonClass});if(j.buttonImage){f.css({"background-image":"url('"+j.buttonImage+"')","text-indent":"-9999px"});}f.html(''+j.buttonText+"").css({height:j.height+"px","line-height":j.height+"px",width:j.width+"px"});l.append(f);c("#"+i.movieName).css({position:"absolute","z-index":1});if(!j.queueID){var k=c("
",{id:j.id+"-queue","class":"uploadify-queue"});l.after(k);i.settings.queueID=j.id+"-queue";i.settings.defaultQueue=true;}i.queueData={files:{},filesSelected:0,filesQueued:0,filesReplaced:0,filesCancelled:0,filesErrored:0,uploadsSuccessful:0,uploadsErrored:0,averageSpeed:0,queueLength:0,queueSize:0,uploadSize:0,queueBytesUploaded:0,uploadQueue:[],errorMsg:"Some files were not added to the queue:"};i.original=m;i.wrapper=l;i.button=f;i.queue=k;if(j.onInit){j.onInit.call(n,i);}}else{if(j.onFallback){j.onFallback.call(n);}}});},cancel:function(d,f){var e=arguments;this.each(function(){var l=c(this),i=l.data("uploadify"),j=i.settings,h=-1;if(e[0]){if(e[0]=="*"){var g=i.queueData.queueLength;c("#"+j.queueID).find(".uploadify-queue-item").each(function(){h++;if(e[1]===true){i.cancelUpload(c(this).attr("id"),false);}else{i.cancelUpload(c(this).attr("id"));}c(this).find(".data").removeClass("data").html(" - Cancelled");c(this).find(".uploadify-progress-bar").remove();c(this).delay(1000+100*h).fadeOut(500,function(){c(this).remove();});});i.queueData.queueSize=0;i.queueData.queueLength=0;if(j.onClearQueue){j.onClearQueue.call(l,g);}}else{for(var m=0;m0){alert(this.queueData.errorMsg);}}if(e.onDialogClose){e.onDialogClose.call(this,this.queueData);}if(e.auto){c("#"+e.id).uploadify("upload","*");}},onSelect:function(g){var h=this.settings;var e={};for(var f in this.queueData.files){e=this.queueData.files[f];if(e.uploaded!=true&&e.name==g.name){var d=confirm('The file named "'+g.name+'" is already in the queue.\nDo you want to replace the existing item in the queue?');if(!d){this.cancelUpload(g.id);this.queueData.filesCancelled++;return false;}else{c("#"+e.id).remove();this.cancelUpload(e.id);this.queueData.filesReplaced++;}}}var i=Math.round(g.size/1024);var l="KB";if(i>1000){i=Math.round(i/1000);l="MB";}var k=i.toString().split(".");i=k[0];if(k.length>1){i+="."+k[1].substr(0,2);}i+=l;var j=g.name;if(j.length>25){j=j.substr(0,25)+"...";}if(c.inArray("onSelect",h.overrideEvents)<0){c("#"+h.queueID).append('
X
'+j+" ("+i+')
');}this.queueData.queueSize+=g.size;this.queueData.files[g.id]=g;if(h.onSelect){h.onSelect.apply(this,arguments);}},onSelectError:function(d,g,f){var e=this.settings;if(c.inArray("onSelectError",e.overrideEvents)<0){switch(g){case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:if(e.queueSizeLimit>f){this.queueData.errorMsg+="\nThe number of files selected exceeds the remaining upload limit ("+f+").";}else{this.queueData.errorMsg+="\nThe number of files selected exceeds the queue size limit ("+e.queueSizeLimit+").";}break;case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:this.queueData.errorMsg+='\nThe file "'+d.name+'" exceeds the size limit ('+e.fileSizeLimit+").";break;case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:this.queueData.errorMsg+='\nThe file "'+d.name+'" is empty.';break;case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:this.queueData.errorMsg+='\nThe file "'+d.name+'" is not an accepted file type ('+e.fileTypeDesc+").";break;}}if(g!=SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){delete this.queueData.files[d.id];}if(e.onSelectError){e.onSelectError.apply(this,arguments);}},onQueueComplete:function(){if(this.settings.onQueueComplete){this.settings.onQueueComplete.call(this,this.settings.queueData);}},onUploadComplete:function(f){var g=this.settings,d=this;var e=this.getStats();this.queueData.queueLength=e.files_queued;if(this.queueData.uploadQueue[0]=="*"){if(this.queueData.queueLength>0){this.startUpload();}else{this.queueData.uploadQueue=[];if(g.onQueueComplete){g.onQueueComplete.call(this,this.queueData);}}}else{if(this.queueData.uploadQueue.length>0){this.startUpload(this.queueData.uploadQueue.shift());}else{this.queueData.uploadQueue=[];if(g.onQueueComplete){g.onQueueComplete.call(this,this.queueData);}}}if(c.inArray("onUploadComplete",g.overrideEvents)<0){if(g.removeCompleted){switch(f.filestatus){case SWFUpload.FILE_STATUS.COMPLETE:setTimeout(function(){if(c("#"+f.id)){d.queueData.queueSize-=f.size;d.queueData.queueLength-=1;delete d.queueData.files[f.id];c("#"+f.id).fadeOut(500,function(){c(this).remove();});}},g.removeTimeout*1000);break;case SWFUpload.FILE_STATUS.ERROR:if(!g.requeueErrors){setTimeout(function(){if(c("#"+f.id)){d.queueData.queueSize-=f.size;d.queueData.queueLength-=1;delete d.queueData.files[f.id];c("#"+f.id).fadeOut(500,function(){c(this).remove();});}},g.removeTimeout*1000);}break;}}else{f.uploaded=true;}}if(g.onUploadComplete){g.onUploadComplete.call(this,f);}},onUploadError:function(e,i,h){var f=this.settings;var g="Error";switch(i){case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:g="HTTP Error ("+h+")";break;case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:g="Missing Upload URL";break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:g="IO Error";break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:g="Security Error";break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:alert("The upload limit has been reached ("+h+").");g="Exceeds Upload Limit";break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:g="Failed";break;case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:break;case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:g="Validation Error";break;case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:g="Cancelled";this.queueData.queueSize-=e.size;this.queueData.queueLength-=1;if(e.status==SWFUpload.FILE_STATUS.IN_PROGRESS||c.inArray(e.id,this.queueData.uploadQueue)>=0){this.queueData.uploadSize-=e.size;}if(f.onCancel){f.onCancel.call(this,e);}delete this.queueData.files[e.id];break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:g="Stopped";break;}if(c.inArray("onUploadError",f.overrideEvents)<0){if(i!=SWFUpload.UPLOAD_ERROR.FILE_CANCELLED&&i!=SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED){c("#"+e.id).addClass("uploadify-error");}c("#"+e.id).find(".uploadify-progress-bar").css("width","1px");if(i!=SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND&&e.status!=SWFUpload.FILE_STATUS.COMPLETE){c("#"+e.id).find(".data").html(" - "+g);}}var d=this.getStats();this.queueData.uploadsErrored=d.upload_errors;if(f.onUploadError){f.onUploadError.call(this,e,i,h,g);}},onUploadProgress:function(g,m,j){var h=this.settings;var e=new Date();var n=e.getTime();var k=n-this.timer;if(k>500){this.timer=n;}var i=m-this.bytesLoaded;this.bytesLoaded=m;var d=this.queueData.queueBytesUploaded+m;var p=Math.round(m/j*100);var o="KB/s";var l=0;var f=(i/1024)/(k/1000);f=Math.floor(f*10)/10;if(this.queueData.averageSpeed>0){this.queueData.averageSpeed=Math.floor((this.queueData.averageSpeed+f)/2);}else{this.queueData.averageSpeed=Math.floor(f);}if(f>1000){l=(f*0.001);this.queueData.averageSpeed=Math.floor(l);o="MB/s";}if(c.inArray("onUploadProgress",h.overrideEvents)<0){if(h.progressData=="percentage"){c("#"+g.id).find(".data").html(" - "+p+"%");}else{if(h.progressData=="speed"&&k>500){c("#"+g.id).find(".data").html(" - "+this.queueData.averageSpeed+o);}}c("#"+g.id).find(".uploadify-progress-bar").css("width",p+"%");}if(h.onUploadProgress){h.onUploadProgress.call(this,g,m,j,d,this.queueData.uploadSize);}},onUploadStart:function(d){var e=this.settings;var f=new Date();this.timer=f.getTime();this.bytesLoaded=0;if(this.queueData.uploadQueue.length==0){this.queueData.uploadSize=d.size;}if(e.checkExisting){c.ajax({type:"POST",async:false,url:e.checkExisting,data:{filename:d.name},success:function(h){if(h==1){var g=confirm('A file with the name "'+d.name+'" already exists on the server.\nWould you like to replace the existing file?');if(!g){this.cancelUpload(d.id);c("#"+d.id).remove();if(this.queueData.uploadQueue.length>0&&this.queueData.queueLength>0){if(this.queueData.uploadQueue[0]=="*"){this.startUpload();}else{this.startUpload(this.queueData.uploadQueue.shift());}}}}}});}if(e.onUploadStart){e.onUploadStart.call(this,d);}},onUploadSuccess:function(f,h,d){var g=this.settings;var e=this.getStats();this.queueData.uploadsSuccessful=e.successful_uploads;this.queueData.queueBytesUploaded+=f.size;if(c.inArray("onUploadSuccess",g.overrideEvents)<0){c("#"+f.id).find(".data").html(" - Complete");}if(g.onUploadSuccess){g.onUploadSuccess.call(this,f,h,d);}}};c.fn.uploadify=function(d){if(b[d]){return b[d].apply(this,Array.prototype.slice.call(arguments,1));}else{if(typeof d==="object"||!d){return b.init.apply(this,arguments);}else{c.error("The method "+d+" does not exist in $.uploadify");}}};})($); \ No newline at end of file diff --git a/web/public_php/ams/js/masonry.pkgd.min.js b/web/public_php/ams/js/masonry.pkgd.min.js index 45642b6be..f0da3709b 100644 --- a/web/public_php/ams/js/masonry.pkgd.min.js +++ b/web/public_php/ams/js/masonry.pkgd.min.js @@ -1,9 +1,9 @@ -/*! - * Masonry PACKAGED v3.1.5 - * Cascading grid layout library - * http://masonry.desandro.com - * MIT License - * by David DeSandro - */ - +/*! + * Masonry PACKAGED v3.1.5 + * Cascading grid layout library + * http://masonry.desandro.com + * MIT License + * by David DeSandro + */ + !function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}return this.each(function(){var d=a.data(this,b);d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d))})}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],c):c(a.jQuery)}(window),function(a){function b(b){var c=a.event;return c.target=c.target||c.srcElement||b,c}var c=document.documentElement,d=function(){};c.addEventListener?d=function(a,b,c){a.addEventListener(b,c,!1)}:c.attachEvent&&(d=function(a,c,d){a[c+d]=d.handleEvent?function(){var c=b(a);d.handleEvent.call(d,c)}:function(){var c=b(a);d.call(a,c)},a.attachEvent("on"+c,a[c+d])});var e=function(){};c.removeEventListener?e=function(a,b,c){a.removeEventListener(b,c,!1)}:c.detachEvent&&(e=function(a,b,c){a.detachEvent("on"+b,a[b+c]);try{delete a[b+c]}catch(d){a[b+c]=void 0}});var f={bind:d,unbind:e};"function"==typeof define&&define.amd?define("eventie/eventie",f):"object"==typeof exports?module.exports=f:a.eventie=f}(this),function(a){function b(a){"function"==typeof a&&(b.isReady?a():f.push(a))}function c(a){var c="readystatechange"===a.type&&"complete"!==e.readyState;if(!b.isReady&&!c){b.isReady=!0;for(var d=0,g=f.length;g>d;d++){var h=f[d];h()}}}function d(d){return d.bind(e,"DOMContentLoaded",c),d.bind(e,"readystatechange",c),d.bind(a,"load",c),b}var e=a.document,f=[];b.isReady=!1,"function"==typeof define&&define.amd?(b.isReady="function"==typeof requirejs,define("doc-ready/doc-ready",["eventie/eventie"],d)):a.docReady=d(a.eventie)}(this),function(){function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;be;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):"object"==typeof exports?module.exports=b:a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function c(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}return a}function d(a){function d(a){if("string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var d=f(a);if("none"===d.display)return c();var e={};e.width=a.offsetWidth,e.height=a.offsetHeight;for(var k=e.isBorderBox=!(!j||!d[j]||"border-box"!==d[j]),l=0,m=g.length;m>l;l++){var n=g[l],o=d[n];o=h(a,o);var p=parseFloat(o);e[n]=isNaN(p)?0:p}var q=e.paddingLeft+e.paddingRight,r=e.paddingTop+e.paddingBottom,s=e.marginLeft+e.marginRight,t=e.marginTop+e.marginBottom,u=e.borderLeftWidth+e.borderRightWidth,v=e.borderTopWidth+e.borderBottomWidth,w=k&&i,x=b(d.width);x!==!1&&(e.width=x+(w?0:q+u));var y=b(d.height);return y!==!1&&(e.height=y+(w?0:r+v)),e.innerWidth=e.width-(q+u),e.innerHeight=e.height-(r+v),e.outerWidth=e.width+s,e.outerHeight=e.height+t,e}}function h(a,b){if(e||-1===b.indexOf("%"))return b;var c=a.style,d=c.left,f=a.runtimeStyle,g=f&&f.left;return g&&(f.left=a.currentStyle.left),c.left=b,b=c.pixelLeft,c.left=d,g&&(f.left=g),b}var i,j=a("boxSizing");return function(){if(j){var a=document.createElement("div");a.style.width="200px",a.style.padding="1px 2px 3px 4px",a.style.borderStyle="solid",a.style.borderWidth="1px 2px 3px 4px",a.style[j]="border-box";var c=document.body||document.documentElement;c.appendChild(a);var d=f(a);i=200===b(d.width),c.removeChild(a)}}(),d}var e=a.getComputedStyle,f=e?function(a){return e(a,null)}:function(a){return a.currentStyle},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],d):"object"==typeof exports?module.exports=d(require("get-style-property")):a.getSize=d(a.getStyleProperty)}(window),function(a,b){function c(a,b){return a[h](b)}function d(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}function e(a,b){d(a);for(var c=a.parentNode.querySelectorAll(b),e=0,f=c.length;f>e;e++)if(c[e]===a)return!0;return!1}function f(a,b){return d(a),c(a,b)}var g,h=function(){if(b.matchesSelector)return"matchesSelector";for(var a=["webkit","moz","ms","o"],c=0,d=a.length;d>c;c++){var e=a[c],f=e+"MatchesSelector";if(b[f])return f}}();if(h){var i=document.createElement("div"),j=c(i,"div");g=j?c:f}else g=e;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return g}):window.matchesSelector=g}(this,Element.prototype),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){for(var b in a)return!1;return b=null,!0}function d(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function e(a,e,f){function h(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}var i=f("transition"),j=f("transform"),k=i&&j,l=!!f("perspective"),m={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[i],n=["transform","transition","transitionDuration","transitionProperty"],o=function(){for(var a={},b=0,c=n.length;c>b;b++){var d=n[b],e=f(d);e&&e!==d&&(a[d]=e)}return a}();b(h.prototype,a.prototype),h.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},h.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},h.prototype.getSize=function(){this.size=e(this.element)},h.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=o[c]||c;b[d]=a[c]}},h.prototype.getPosition=function(){var a=g(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=parseInt(a[c?"left":"right"],10),f=parseInt(a[d?"top":"bottom"],10);e=isNaN(e)?0:e,f=isNaN(f)?0:f;var h=this.layout.size;e-=c?h.paddingLeft:h.paddingRight,f-=d?h.paddingTop:h.paddingBottom,this.position.x=e,this.position.y=f},h.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={};b.isOriginLeft?(c.left=this.position.x+a.paddingLeft+"px",c.right=""):(c.right=this.position.x+a.paddingRight+"px",c.left=""),b.isOriginTop?(c.top=this.position.y+a.paddingTop+"px",c.bottom=""):(c.bottom=this.position.y+a.paddingBottom+"px",c.top=""),this.css(c),this.emitEvent("layout",[this])};var p=l?function(a,b){return"translate3d("+a+"px, "+b+"px, 0)"}:function(a,b){return"translate("+a+"px, "+b+"px)"};h.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),f=parseInt(b,10),g=e===this.position.x&&f===this.position.y;if(this.setPosition(a,b),g&&!this.isTransitioning)return void this.layoutPosition();var h=a-c,i=b-d,j={},k=this.layout.options;h=k.isOriginLeft?h:-h,i=k.isOriginTop?i:-i,j.transform=p(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},h.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},h.prototype.moveTo=k?h.prototype._transitionTo:h.prototype.goTo,h.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},h.prototype._nonTransition=function(a){this.css(a.to),a.isCleaning&&this._removeStyles(a.to);for(var b in a.onTransitionEnd)a.onTransitionEnd[b].call(this)},h.prototype._transition=function(a){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(a);var b=this._transn;for(var c in a.onTransitionEnd)b.onEnd[c]=a.onTransitionEnd[c];for(c in a.to)b.ingProperties[c]=!0,a.isCleaning&&(b.clean[c]=!0);if(a.from){this.css(a.from);var d=this.element.offsetHeight;d=null}this.enableTransition(a.to),this.css(a.to),this.isTransitioning=!0};var q=j&&d(j)+",opacity";h.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:q,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(m,this,!1))},h.prototype.transition=h.prototype[i?"_transition":"_nonTransition"],h.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},h.prototype.onotransitionend=function(a){this.ontransitionend(a)};var r={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};h.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,d=r[a.propertyName]||a.propertyName;if(delete b.ingProperties[d],c(b.ingProperties)&&this.disableTransition(),d in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[d]),d in b.onEnd){var e=b.onEnd[d];e.call(this),delete b.onEnd[d]}this.emitEvent("transitionEnd",[this])}},h.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(m,this,!1),this.isTransitioning=!1},h.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var s={transitionProperty:"",transitionDuration:""};return h.prototype.removeTransitionStyles=function(){this.css(s)},h.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.emitEvent("remove",[this])},h.prototype.remove=function(){if(!i||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.on("transitionEnd",function(){return a.removeElem(),!0}),this.hide()},h.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options;this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0})},h.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options;this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:{opacity:function(){this.isHidden&&this.css({display:"none"})}}})},h.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},h}var f=a.getComputedStyle,g=f?function(a){return f(a,null)}:function(a){return a.currentStyle};"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property"],e):(a.Outlayer={},a.Outlayer.Item=e(a.EventEmitter,a.getSize,a.getStyleProperty))}(window),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){return"[object Array]"===l.call(a)}function d(a){var b=[];if(c(a))b=a;else if(a&&"number"==typeof a.length)for(var d=0,e=a.length;e>d;d++)b.push(a[d]);else b.push(a);return b}function e(a,b){var c=n(b,a);-1!==c&&b.splice(c,1)}function f(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()}function g(c,g,l,n,o,p){function q(a,c){if("string"==typeof a&&(a=h.querySelector(a)),!a||!m(a))return void(i&&i.error("Bad "+this.constructor.namespace+" element: "+a));this.element=a,this.options=b({},this.constructor.defaults),this.option(c);var d=++r;this.element.outlayerGUID=d,s[d]=this,this._create(),this.options.isInitLayout&&this.layout()}var r=0,s={};return q.namespace="outlayer",q.Item=p,q.defaults={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,isResizingContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},b(q.prototype,l.prototype),q.prototype.option=function(a){b(this.options,a)},q.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),b(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},q.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},q.prototype._itemize=function(a){for(var b=this._filterFindItemElements(a),c=this.constructor.Item,d=[],e=0,f=b.length;f>e;e++){var g=b[e],h=new c(g,this);d.push(h)}return d},q.prototype._filterFindItemElements=function(a){a=d(a);for(var b=this.options.itemSelector,c=[],e=0,f=a.length;f>e;e++){var g=a[e];if(m(g))if(b){o(g,b)&&c.push(g);for(var h=g.querySelectorAll(b),i=0,j=h.length;j>i;i++)c.push(h[i])}else c.push(g)}return c},q.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},q.prototype.layout=function(){this._resetLayout(),this._manageStamps();var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,a),this._isLayoutInited=!0},q.prototype._init=q.prototype.layout,q.prototype._resetLayout=function(){this.getSize()},q.prototype.getSize=function(){this.size=n(this.element)},q.prototype._getMeasurement=function(a,b){var c,d=this.options[a];d?("string"==typeof d?c=this.element.querySelector(d):m(d)&&(c=d),this[a]=c?n(c)[b]:d):this[a]=0},q.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},q.prototype._getItemsForLayout=function(a){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];e.isIgnored||b.push(e)}return b},q.prototype._layoutItems=function(a,b){function c(){d.emitEvent("layoutComplete",[d,a])}var d=this;if(!a||!a.length)return void c();this._itemsOn(a,"layout",c);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f],i=this._getItemLayoutPosition(h);i.item=h,i.isInstant=b||h.isLayoutInstant,e.push(i)}this._processLayoutQueue(e)},q.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},q.prototype._processLayoutQueue=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];this._positionItem(d.item,d.x,d.y,d.isInstant)}},q.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},q.prototype._postLayout=function(){this.resizeContainer()},q.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},q.prototype._getContainerSize=k,q.prototype._setContainerMeasure=function(a,b){if(void 0!==a){var c=this.size;c.isBorderBox&&(a+=b?c.paddingLeft+c.paddingRight+c.borderLeftWidth+c.borderRightWidth:c.paddingBottom+c.paddingTop+c.borderTopWidth+c.borderBottomWidth),a=Math.max(a,0),this.element.style[b?"width":"height"]=a+"px"}},q.prototype._itemsOn=function(a,b,c){function d(){return e++,e===f&&c.call(g),!0}for(var e=0,f=a.length,g=this,h=0,i=a.length;i>h;h++){var j=a[h];j.on(b,d)}},q.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},q.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored},q.prototype.stamp=function(a){if(a=this._find(a)){this.stamps=this.stamps.concat(a);for(var b=0,c=a.length;c>b;b++){var d=a[b];this.ignore(d)}}},q.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e(d,this.stamps),this.unignore(d)}},q.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=d(a)):void 0},q.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var a=0,b=this.stamps.length;b>a;a++){var c=this.stamps[a];this._manageStamp(c)}}},q.prototype._getBoundingRect=function(){var a=this.element.getBoundingClientRect(),b=this.size;this._boundingRect={left:a.left+b.paddingLeft+b.borderLeftWidth,top:a.top+b.paddingTop+b.borderTopWidth,right:a.right-(b.paddingRight+b.borderRightWidth),bottom:a.bottom-(b.paddingBottom+b.borderBottomWidth)}},q.prototype._manageStamp=k,q.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,d=n(a),e={left:b.left-c.left-d.marginLeft,top:b.top-c.top-d.marginTop,right:c.right-b.right-d.marginRight,bottom:c.bottom-b.bottom-d.marginBottom};return e},q.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},q.prototype.bindResize=function(){this.isResizeBound||(c.bind(a,"resize",this),this.isResizeBound=!0)},q.prototype.unbindResize=function(){this.isResizeBound&&c.unbind(a,"resize",this),this.isResizeBound=!1},q.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},q.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},q.prototype.needsResizeLayout=function(){var a=n(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},q.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},q.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},q.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){var c=this.items.slice(0);this.items=b.concat(c),this._resetLayout(),this._manageStamps(),this.layoutItems(b,!0),this.reveal(b),this.layoutItems(c)}},q.prototype.reveal=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.reveal()}},q.prototype.hide=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.hide()}},q.prototype.getItem=function(a){for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];if(d.element===a)return d}},q.prototype.getItems=function(a){if(a&&a.length){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c],f=this.getItem(e);f&&b.push(f)}return b}},q.prototype.remove=function(a){a=d(a);var b=this.getItems(a);if(b&&b.length){this._itemsOn(b,"remove",function(){this.emitEvent("removeComplete",[this,b])});for(var c=0,f=b.length;f>c;c++){var g=b[c];g.remove(),e(g,this.items)}}},q.prototype.destroy=function(){var a=this.element.style;a.height="",a.position="",a.width="";for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];d.destroy()}this.unbindResize(),delete this.element.outlayerGUID,j&&j.removeData(this.element,this.constructor.namespace)},q.data=function(a){var b=a&&a.outlayerGUID;return b&&s[b]},q.create=function(a,c){function d(){q.apply(this,arguments)}return Object.create?d.prototype=Object.create(q.prototype):b(d.prototype,q.prototype),d.prototype.constructor=d,d.defaults=b({},q.defaults),b(d.defaults,c),d.prototype.settings={},d.namespace=a,d.data=q.data,d.Item=function(){p.apply(this,arguments)},d.Item.prototype=new p,g(function(){for(var b=f(a),c=h.querySelectorAll(".js-"+b),e="data-"+b+"-options",g=0,k=c.length;k>g;g++){var l,m=c[g],n=m.getAttribute(e);try{l=n&&JSON.parse(n)}catch(o){i&&i.error("Error parsing "+e+" on "+m.nodeName.toLowerCase()+(m.id?"#"+m.id:"")+": "+o);continue}var p=new d(m,l);j&&j.data(m,a,p)}}),j&&j.bridget&&j.bridget(a,d),d},q.Item=p,q}var h=a.document,i=a.console,j=a.jQuery,k=function(){},l=Object.prototype.toString,m="object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1===a.nodeType&&"string"==typeof a.nodeName},n=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1};"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","doc-ready/doc-ready","eventEmitter/EventEmitter","get-size/get-size","matches-selector/matches-selector","./item"],g):a.Outlayer=g(a.eventie,a.docReady,a.EventEmitter,a.getSize,a.matchesSelector,a.Outlayer.Item)}(window),function(a){function b(a,b){var d=a.create("masonry");return d.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0);this.maxY=0},d.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var a=this.items[0],c=a&&a.element;this.columnWidth=c&&b(c).outerWidth||this.containerWidth}this.columnWidth+=this.gutter,this.cols=Math.floor((this.containerWidth+this.gutter)/this.columnWidth),this.cols=Math.max(this.cols,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);this.containerWidth=c&&c.innerWidth},d.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth%this.columnWidth,d=b&&1>b?"round":"ceil",e=Math[d](a.size.outerWidth/this.columnWidth);e=Math.min(e,this.cols);for(var f=this._getColGroup(e),g=Math.min.apply(Math,f),h=c(f,g),i={x:this.columnWidth*h,y:g},j=g+a.size.outerHeight,k=this.cols+1-f.length,l=0;k>l;l++)this.colYs[h+l]=j;return i},d.prototype._getColGroup=function(a){if(2>a)return this.colYs;for(var b=[],c=this.cols+1-a,d=0;c>d;d++){var e=this.colYs.slice(d,d+a);b[d]=Math.max.apply(Math,e)}return b},d.prototype._manageStamp=function(a){var c=b(a),d=this._getElementOffset(a),e=this.options.isOriginLeft?d.left:d.right,f=e+c.outerWidth,g=Math.floor(e/this.columnWidth);g=Math.max(0,g);var h=Math.floor(f/this.columnWidth);h-=f%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var i=(this.options.isOriginTop?d.top:d.bottom)+c.outerHeight,j=g;h>=j;j++)this.colYs[j]=Math.max(i,this.colYs[j])},d.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var a={height:this.maxY};return this.options.isFitWidth&&(a.width=this._getContainerFitWidth()),a},d.prototype._getContainerFitWidth=function(){for(var a=0,b=this.cols;--b&&0===this.colYs[b];)a++;return(this.cols-a)*this.columnWidth-this.gutter},d.prototype.needsResizeLayout=function(){var a=this.containerWidth;return this.getContainerWidth(),a!==this.containerWidth},d}var c=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e===b)return c}return-1};"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size"],b):a.Masonry=b(a.Outlayer,a.getSize)}(window); \ No newline at end of file