#include <properties.h>#include <ansi.h>#include <combat.h>#include <language.h>#include "invmaster.h"

gehe zum Quellcode dieser Datei
Funktionen | |
| static string | Mapping2ColoredText (mapping pic, object player) |
| static string | Mapping2PlainText (mapping pic) |
| static void | AddDescription (mapping pic, string type, object item) |
| static string | ComposeDesc (object item) |
| static void | ConfigureColors (string text) |
| void | ShowInv (object player, string arg) |
| void | create () |
| string | SimpleInv (object player) |
Variablen | |
| mapping | data |
| closure | abbreviate |
| static string * | armour_types |
| static mapping | colors |
| static mapping | bgcolors |
| string * | armour_order |
| mapping | weapon_names |
| static void AddDescription | ( | mapping | pic, | |
| string | type, | |||
| object | item | |||
| ) | [static] |
Definiert in Zeile 206 der Datei invmaster.c.
Benutzt AT_AMULET, AT_ARMOUR, AT_BELT, AT_BOOT, AT_CLOAK, AT_GLOVE, AT_HELMET, AT_QUIVER, AT_RING, AT_SHIELD, AT_TROUSERS und ComposeDesc().
Wird benutzt von ShowInv().
00207 { 00208 int indentx, indenty, i; 00209 string text; 00210 00211 switch(type) 00212 { 00213 case AT_HELMET: 00214 indentx=47; 00215 indenty=0; 00216 text=sprintf("%-30s",ComposeDesc(item)[0..30]);break; 00217 case AT_QUIVER: 00218 indentx=49; 00219 indenty=2; 00220 text=sprintf("%-28s",ComposeDesc(item)[0..28]);break; 00221 case AT_AMULET: 00222 indentx=49; 00223 indenty=4; 00224 text=sprintf("%-27s",ComposeDesc(item)[0..28]);break; 00225 case AT_ARMOUR: 00226 indentx=53; 00227 indenty=7; 00228 text=sprintf("%-24s",ComposeDesc(item)[0..25]);break; 00229 case AT_SHIELD: 00230 indentx=54; 00231 indenty=10; 00232 text=sprintf("%-20s",ComposeDesc(item)[0..24]);break; 00233 case AT_CLOAK: 00234 indentx=53; 00235 indenty=15; 00236 text=sprintf("%-20s",ComposeDesc(item)[0..25]);break; 00237 case AT_TROUSERS: 00238 indentx=49; 00239 indenty=17; 00240 text=sprintf("%-20s",ComposeDesc(item)[0..20]);break; 00241 case AT_RING: 00242 indentx=0; 00243 indenty=9; 00244 text=sprintf("%14s",ComposeDesc(item)[0..17]);break; 00245 case AT_GLOVE: 00246 indentx=0; 00247 indenty=11; 00248 text=sprintf("%14s",ComposeDesc(item)[0..17]);break; 00249 case AT_BELT: 00250 indentx=1; 00251 indenty=13; 00252 text=sprintf("%14s",ComposeDesc(item)[0..18]);break; 00253 case AT_BOOT: 00254 indentx=1; 00255 indenty=20; 00256 text=sprintf("%18s",ComposeDesc(item)[0..18]);break; 00257 case "Waffe": 00258 indentx=1; 00259 indenty=1; 00260 text=sprintf("%18s",ComposeDesc(item)[0..25]); 00261 if (item->QueryProp(P_NR_HANDS) > 1 && 00262 this_player() && 00263 !(this_player()->QueryArmorByType(AT_SHIELD))) 00264 AddDescription(pic, AT_SHIELD, item);break; 00265 default: return; 00266 } 00267 for (i=0;i<strlen(text);i++) 00268 pic+=([(80*indenty+indentx+i):text[i..i];2]); 00269 }


| static string ComposeDesc | ( | object | item | ) | [static] |
Definiert in Zeile 139 der Datei invmaster.c.
Benutzt abbreviate, P_NAME und P_SHORT.
Wird benutzt von AddDescription().
00140 { 00141 int i; 00142 string text, *buff; 00143 00144 text=regreplace(item->QueryProp(P_SHORT) 00145 ||item->QueryProp(P_NAME) 00146 ||"<?>", 00147 "^(Ein Paar|Ein|Eine|Der|Die|Das) ","",0); 00148 00149 // try to shorten the name with the closure 00150 if (strlen(text) > 20) 00151 return implode(map(explode(text, " "), abbreviate), " "); 00152 else 00153 return text; 00154 }

| static varargs void ConfigureColors | ( | string | text | ) | [static] |
Definiert in Zeile 271 der Datei invmaster.c.
Benutzt break_string(), COLORCODES, COLORNAMES, default_config, F_MODE_AD, F_MODE_AS, InFight(), input_to(), P_INVMASTER_CONFIG und SAVE.
Wird benutzt von ShowInv().
00272 { 00273 mapping config, display; 00274 string *strs; 00275 00276 if (!objectp(this_player())) return; 00277 00278 if (this_player()->InFight()) 00279 { 00280 write(break_string( 00281 "Im Kampf? Na Du hast Nerven, das lassen wir doch mal lieber! " 00282 "Probier es danach nochmal...", 78)); 00283 return; 00284 } 00285 00286 if (stringp(text)) text=lower_case(text); 00287 00288 if (text=="ok") 00289 { 00290 write("Farbkonfiguration beendet.\n"); 00291 return; 00292 } 00293 00294 //"ansi_config", def in invmaster.h 00295 config=this_player()->QueryProp(P_INVMASTER_CONFIG)||([]); 00296 display=default_config+config; 00297 00298 if (!text || text=="") 00299 { 00300 write( 00301 "*** Farbkonfiguration fuer den Ausruestungsbefehl ***\n\n" 00302 " Farbe: wird dargestellt mit:\n" 00303 "------------------ --------------------\n" 00304 " Hintergrund "+COLORNAMES[display[8]]+"\n" 00305 " Schwarz "+COLORNAMES[display[0]]+"\n" 00306 " Rot "+COLORNAMES[display[1]]+"\n" 00307 " Gruen "+COLORNAMES[display[2]]+"\n" 00308 " Gelb "+COLORNAMES[display[3]]+"\n" 00309 " Blau "+COLORNAMES[display[4]]+"\n" 00310 " Magenta "+COLORNAMES[display[5]]+"\n" 00311 " Tuerkis "+COLORNAMES[display[6]]+"\n" 00312 " Weiss "+COLORNAMES[display[7]]+"\n\n" 00313 "Farbe aendern mit '<farbe> <gewuenschte farbe>'.\n" 00314 "Beispiel: 'gelb rot'.\n" 00315 "Alles, was standardmaessig gelb waere, wuerde dann mit der ANSI-Farbe \n" 00316 "Rot dargestellt.\n" 00317 "Der Hintergrund kann zusaetzlich die Farbe 'keine' haben, bei der der \n" 00318 "Hintergrund eben ueberhaupt nicht gefaerbt wird.\n" 00319 "Beispiel: 'hintergrund keine'. Schaltet die Hintergrundfarbe aus.\n\n" 00320 "Beenden mit 'ok'. \n" 00321 "Wiederholung der Farbliste mit <Return>.\n" 00322 "Farbliste auf Standard zuruecksetzen mit 'reset'.\n"); 00323 } 00324 else 00325 if (text=="reset") 00326 { 00327 this_player()->Set(P_INVMASTER_CONFIG, SAVE, F_MODE_AD); 00328 this_player()->SetProp(P_INVMASTER_CONFIG, 0); 00329 write("Farben zurueckgesetzt!\n"); 00330 } 00331 else 00332 { 00333 if ( sizeof(strs=explode(text, " ")-({""})) !=2 00334 || !member((COLORCODES-(["keine"])), strs[0]) 00335 || !member((COLORCODES-(["hintergrund"])), strs[1]) 00336 || ((strs[0]!="hintergrund") && (strs[1]=="keine")) ) 00337 { 00338 write("Falsche Eingabe.\n" 00339 "Format: <farbe|hintergrund> <zugewiesene Farbe>\n" 00340 "Abbrechen mit 'ok'.\n"); 00341 } 00342 else 00343 { 00344 if (COLORCODES[strs[1]]==default_config[COLORCODES[strs[0]]]) 00345 config-=([COLORCODES[strs[0]]]); 00346 else 00347 config+=([COLORCODES[strs[0]]:COLORCODES[strs[1]]]); 00348 if (!sizeof(config)) 00349 { 00350 this_player()->Set(P_INVMASTER_CONFIG, SAVE, F_MODE_AD); 00351 this_player()->SetProp(P_INVMASTER_CONFIG, 0); 00352 } 00353 else 00354 { 00355 this_player()->SetProp(P_INVMASTER_CONFIG, deep_copy(config)); 00356 this_player()->Set(P_INVMASTER_CONFIG, SAVE, F_MODE_AS); 00357 } 00358 write("Ok, Farbe gewaehlt!\n"); 00359 } 00360 } 00361 write("\nEingabe: "); 00362 input_to("ConfigureColors"); 00363 }


| void create | ( | ) |
Definiert in Zeile 72 der Datei invmaster.c.
Benutzt abbreviate, data, DB, i, INVPATH, lines, text() und x.
00073 { 00074 mapping pic; 00075 string *files, *lines, text; 00076 int i,j,k, indentx,indenty, color; 00077 00078 data=([]); 00079 00080 DB("Trying to fire up master, path is '"+INVPATH+"'..."); 00081 files=get_dir(INVPATH+"gfx/*")-({".", ".."}); 00082 DB(sprintf("Files found in 'gfx/': \n%O", files)); 00083 for (i=sizeof(files)-1;i>=0;i--) 00084 { 00085 DB("Reading '"+files[i]+"' ..."); 00086 text=read_file(INVPATH+"gfx/"+files[i]); 00087 if (!stringp(text)) 00088 { 00089 DB("Failed to read file."); 00090 continue; 00091 } 00092 lines=explode(text, "\n"); 00093 if (sizeof(lines) < 4) 00094 { 00095 DB("File corrupt."); 00096 continue; 00097 } 00098 indentx=to_int(lines[1]); 00099 indenty=to_int(lines[2]); 00100 color=to_int(lines[0]); 00101 pic=([]); 00102 for (j=sizeof(lines)-1;j>2;j--) 00103 { 00104 for (k=strlen(lines[j])-1;k>=0;k--) 00105 { 00106 if (lines[j][k..k]!="?") 00107 pic+=([(j-3+indenty)*80+k+indentx:lines[j][k..k];color]); 00108 } 00109 } 00110 data+=([files[i]:pic]); 00111 DB("File successfully read."); 00112 } 00113 DB(sprintf("Types covered:\n%O\n", m_indices(data))); 00114 00115 // create closure only once to save time 00116 // needed by ComposeDesc() 00117 // the closure ist not as complicated as it seems ;) 00118 // it just checks every word of the name, if it does not begin 00119 // with a capital letter, it is abbreviated 00120 // this happens only if the name length exceeds 20 chars... 00121 abbreviate=lambda(({'x}), 00122 ({#'?, ({#'>, ({#'member, quote(({"der", "des"})), 'x}), 0}), 00123 "d.", 00124 ({#'?, ({#'>, ({#'strlen, 'x}), 3}), 00125 ({#'?, ({#',, ({#'=, 'a, ({#'allocate, 1}) }), 00126 ({#'=, ({#'[, 'a, 0}), 'x }), 00127 ({#'sizeof, ({#'regexp, 'a, "^[a-z].*"}) }) 00128 }), 00129 ({#'+, ({#'extract, 'x, 0, 1}), "."}), 00130 'x 00131 }), 00132 'x 00133 }) 00134 })); 00135 }

| static string Mapping2ColoredText | ( | mapping | pic, | |
| object | player | |||
| ) | [static] |
Definiert in Zeile 163 der Datei invmaster.c.
Benutzt ANSI_NORMAL, bgcolors, colors, default_config und P_INVMASTER_CONFIG.
Wird benutzt von ShowInv().
00164 { 00165 string text; 00166 mapping configmap; 00167 int i,j,color; 00168 00169 configmap=default_config+(player->QueryProp(P_INVMASTER_CONFIG)||([])); 00170 00171 text=""; 00172 color=0; 00173 for (i=0;i<22;i++) 00174 { 00175 text+=bgcolors[configmap[8]]; 00176 for (j=0;j<78;j++) 00177 { 00178 if (pic[i*80+j,1]!=color) 00179 { 00180 color=pic[i*80+j,1]; 00181 text+=colors[configmap[color]]; 00182 } 00183 text+=pic[i*80+j]; 00184 } 00185 text+=ANSI_NORMAL+"\n"; 00186 color=0; 00187 } 00188 return text; 00189 }

| static string Mapping2PlainText | ( | mapping | pic | ) | [static] |
Definiert in Zeile 191 der Datei invmaster.c.
Wird benutzt von ShowInv().
00192 { 00193 string text; 00194 int i,j; 00195 00196 text=""; 00197 00198 for (i=0;i<22;i++) 00199 { 00200 for (j=0;j<78;j++) 00201 text+=pic[i*80+j]; 00202 text+="\n"; 00203 } 00204 return text; 00205 }

| void ShowInv | ( | object | player, | |
| string | arg | |||
| ) |
Definiert in Zeile 415 der Datei invmaster.c.
Benutzt AddDescription(), armour_types, ConfigureColors(), data, DB, FEMALE, gender, item, Mapping2ColoredText(), Mapping2PlainText(), P_GENDER, P_NO_ASCII_ART, P_TTY, P_WEAPON, P_WEAPON_TYPE, SimpleInv(), VALID_WEAPON_TYPE und WT_MISC.
00416 { 00417 string gender, type; 00418 mapping pic; 00419 int i; 00420 object item; 00421 00422 if (!objectp(player)||!interactive(player)) return; 00423 00424 // split args. 00425 string *args; 00426 if (stringp(arg)) 00427 args = explode(lower_case(arg), " ") - ({" "}); 00428 else 00429 args = ({}); 00430 00431 if (member(args, "farben") > -1) { 00432 ConfigureColors(); 00433 return; 00434 } 00435 00436 if (member(args, "-k") > -1 || player->QueryProp(P_NO_ASCII_ART)) { 00437 tell_object(player, SimpleInv(player)); 00438 return; 00439 } 00440 00441 gender=player->QueryProp(P_GENDER)==FEMALE?"_female":"_male"; 00442 pic=deep_copy(data["base"+gender]); 00443 pic+=data["Beschriftung"]; 00444 for (i=sizeof(armour_types)-1;i>=0;i--) 00445 if (objectp(item=player->QueryArmourByType(armour_types[i]))) 00446 { 00447 pic+=data[armour_types[i]+gender]; 00448 AddDescription(pic, armour_types[i], item); 00449 } 00450 if (item=player->QueryProp(P_WEAPON)) 00451 { 00452 pic+=data[(VALID_WEAPON_TYPE(type=item->QueryProp(P_WEAPON_TYPE)))? 00453 type:WT_MISC]; 00454 AddDescription(pic, "Waffe", item); 00455 } 00456 if (player->QueryProp(P_TTY)!="ansi") 00457 player->More(Mapping2PlainText(pic)); 00458 else 00459 player->More(Mapping2ColoredText(pic, player)); 00460 DB(geteuid(player)+" eval cost: "+(1000000-get_eval_cost())+" ticks.\n"); 00461 }

| string SimpleInv | ( | object | player | ) |
Definiert in Zeile 384 der Datei invmaster.c.
Benutzt armours, count, list, ob(), P_ARMOUR_TYPE, P_ARMOURS, P_SHORT, P_WEAPON, P_WEAPON_TYPE und result().
Wird benutzt von ShowInv().
00384 { 00385 object* armours=player->QueryProp(P_ARMOURS); 00386 int count=sizeof(armour_order),i; 00387 string* list=allocate(count); 00388 string result="Ausruestung\n"; 00389 object ob; 00390 00391 for(i=sizeof(armours)-1;i>=0 && objectp(ob=armours[i]);i--) { 00392 int idx=member(armour_order,ob->QueryProp(P_ARMOUR_TYPE)); 00393 if (idx>=0) 00394 list[idx]=ob->QueryProp(P_SHORT); 00395 } 00396 00397 // AT_MISC weglassen 00398 for (i=0;i<count-1;i++) { 00399 result+=sprintf("%-20s %-57s\n",armour_order[i],list[i] || ""); 00400 } 00401 ob=ob=player->QueryProp(P_WEAPON); 00402 if (objectp(ob)) { 00403 result+=sprintf("%-20s %-57s\n", 00404 (ob->QueryProp(P_NR_HANDS)==1 ? "Einhand-":"Zweihand-") 00405 +weapon_names[ob->QueryProp(P_WEAPON_TYPE)], 00406 ob->QueryProp(P_SHORT)); 00407 } else result+="Keine Waffe\n"; 00408 00409 return result; 00410 }


| closure abbreviate |
Definiert in Zeile 18 der Datei invmaster.c.
Wird benutzt von ComposeDesc() und create().
| string* armour_order |
string* armour_types [static] |
mapping bgcolors [static] |
([0:ANSI_BG_BLACK, 1:ANSI_BG_RED, 2:ANSI_BG_GREEN, 3:ANSI_BG_YELLOW, 4:ANSI_BG_BLUE, 5:ANSI_BG_PURPLE, 6:ANSI_BG_CYAN, 7:ANSI_BG_WHITE, 8:""])
Definiert in Zeile 48 der Datei invmaster.c.
Wird benutzt von Mapping2ColoredText().
mapping colors [static] |
([0:ANSI_BLACK, 1:ANSI_RED, 2:ANSI_GREEN, 3:ANSI_YELLOW, 4:ANSI_BLUE, 5:ANSI_PURPLE, 6:ANSI_CYAN, 7:ANSI_WHITE, 8:""])
Definiert in Zeile 37 der Datei invmaster.c.
Wird benutzt von Mapping2ColoredText().
| mapping data |
Definiert in Zeile 17 der Datei invmaster.c.
| mapping weapon_names |
1.6.3