Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- //#define _DEBUG 1
- #define _YSI_SPECIAL_DEBUG
- // Define HUGE space in this version!
- #define XML_WRITE_BUFFER_SIZE (8192)
- #include <a_samp>
- #include <sscanf2>
- #include <YSI\y_classes>
- #include <YSI\y_xml>
- #include <YSI\y_ini>
- #include <YSI\y_commands>
- #include <YSI\y_text>
- #include <YSI\y_stringhash>
- public OnFilterScriptInit()
- {
- printf("LANGUAGE: %d", _:Langs_AddLanguage("EN", "English"));
- }
- text style_generate[all], core[ysi_help];
- new
- XMLEntry:gWriteRoot,
- XMLEntry:gWriteCur,
- gPrevTag[MAX_INI_TAG] = "\1\0";
- // Common language formats. DO NOT load the y_text code in here as we don't
- // care about it.
- forward TextLoader(tag[], name[], value[]);
- public TextLoader(tag[], name[], value[])
- {
- printf("loading %s %s", tag, name);
- if (strcmp(gPrevTag, tag))
- {
- strcpy(gPrevTag, tag);
- gWriteCur = XML_AddParameter(gWriteRoot, "group");
- XML_AddParameter(gWriteCur, "name", tag);
- }
- new
- XMLEntry:ctag = XML_AddParameter(gWriteCur, "entry");
- XML_AddParameter(ctag, "name", name);
- XML_AddParameter(ctag, "style", "client");
- XML_AddParameter(ctag, "colour", "X11_RED");
- }
- new
- XMLEntry:gTextDraws[1024] = {XML_NO_WRITE, ...};//,
- //BitArray:gUseBox<1024> = {Bit:-1, ...};
- forward TDELoader(tag[], name[], value[]);
- public TDELoader(tag[], name[], value[])
- {
- printf("getting %s %s", tag, name);
- new
- offset = strfind(name, "_") + 1;
- if (!offset)
- {
- return;
- }
- new
- id = strval(name);
- if (gTextDraws[id] == XML_NO_WRITE)
- {
- gTextDraws[id] = XML_AddParameter(gWriteRoot, "textdraw");
- new
- nm[32];
- // Generate a name for this TD from the filename and ID.
- format(nm, sizeof (nm), "%s_%04d", gPrevTag, id);
- XML_AddParameter(gTextDraws[id], "name", nm);
- }
- switch (YHash(name[offset], false))
- {
- case _I(X):
- {
- XML_AddParameter(gTextDraws[id], "x", value);
- }
- case _I(Y):
- {
- XML_AddParameter(gTextDraws[id], "y", value);
- }
- case _I(A,l,i,g,n,m,e,n,t):
- {
- XML_AddParameter(gTextDraws[id], "alignment", value);
- }
- case _I(B,a,c,k,C,o,l,o,r):
- {
- XML_AddParameter(gTextDraws[id], "background", value);
- }
- /*case _I(U,s,e,B,o,x):
- {
- XML_AddParameter(gTextDraws[id], "X", value);
- }*/
- case _I(B,o,x,C,o,l,o,r):
- {
- XML_AddParameter(gTextDraws[id], "box", value);
- }
- case _I(T,e,x,t,S,i,z,e,X):
- {
- XML_AddParameter(gTextDraws[id], "textx", value);
- }
- case _I(T,e,x,t,S,i,z,e,Y):
- {
- XML_AddParameter(gTextDraws[id], "texty", value);
- }
- case _I(C,o,l,o,r):
- {
- XML_AddParameter(gTextDraws[id], "color", value);
- }
- case _I(F,o,n,t):
- {
- XML_AddParameter(gTextDraws[id], "font", value);
- }
- case _I(X,S,i,z,e):
- {
- XML_AddParameter(gTextDraws[id], "letterx", value);
- }
- case _I(Y,S,i,z,e):
- {
- XML_AddParameter(gTextDraws[id], "lettery", value);
- }
- case _I(O,u,t,l,i,n,e):
- {
- XML_AddParameter(gTextDraws[id], "outline", value);
- }
- case _I(P,r,o,p,o,r,t,i,o,n,a,l):
- {
- XML_AddParameter(gTextDraws[id], "proportional", value);
- }
- case _I(S,h,a,d,o,w):
- {
- XML_AddParameter(gTextDraws[id], "shadow", value);
- }
- }
- }
- YCMD:style_generate(playerid, params[], help)
- {
- if (help) Text_Send(playerid, STYLE_GENERATE_HELP);
- else if (isnull(params)) Text_Send(playerid, STYLE_GENERATE_PARAMS);
- else
- {
- new
- fname[64];
- gWriteRoot = XML_AddItem("YML");
- gPrevTag = "\1\0";
- format(fname, sizeof (fname), "YSI/text/%s.EN", params);
- INI_ParseFile(fname, "TextLoader", .bPassTag = true);
- format(fname, sizeof (fname), "YSI/%s_LANG_DATA.yml", params);
- XML_WriteItem(fname, gWriteRoot, false, true);
- }
- return 1;
- }
- YCMD:style_convert(playerid, params[], help)
- {
- printf("Style_Convert");
- if (help) Text_Send(playerid, STYLE_CONVERT_HELP);
- else if (isnull(params)) Text_Send(playerid, STYLE_CONVERT_PARAMS);
- else
- {
- for (new i = 0; i != sizeof (gTextDraws); ++i)
- {
- gTextDraws[i] = XML_NO_WRITE;
- }
- new
- fname[64];
- gWriteRoot = XML_AddItem("YML");
- gPrevTag = "\1\0";
- format(fname, sizeof (fname), "%s.TDE", params);
- strcpy(gPrevTag, params);
- INI_ParseFile(fname, "TDELoader", .bPassTag = true);
- format(fname, sizeof (fname), "YSI/%s.yml", params);
- XML_WriteItem(fname, gWriteRoot, false, true);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment