Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom item color in lists for magic weapons/items #285

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
96bbaba
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
9c3847f
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
6f57469
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
71cd4fa
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
e59601c
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
005f94f
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
37c6be6
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
a409ce3
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
29d6244
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
b3961ef
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
76fe224
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
2836c34
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
d68649b
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
6a7f72d
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
bd2685c
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
d784335
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
01dfb59
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
1bd3537
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
cf18334
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
ba2e7ce
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
53fb05d
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
fce12a4
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
d60d259
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
fb60c7f
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
d21acd3
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
99b4b53
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
0d93ad1
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
6404f25
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
3c355ca
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
91f6f2e
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
0afad11
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
6037401
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
1a9b550
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
b256b53
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
65be095
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
cf4e422
Add custom item color in lists for magic weapons/items
Nagath Nov 13, 2014
e2d0f1d
Update potion.kod
Nagath Nov 17, 2014
eb18e41
Update scroll.kod
Nagath Nov 17, 2014
f283a56
Update chalice.kod
Nagath Nov 17, 2014
72f0790
Update chalice.kod
Nagath Nov 17, 2014
bc80c65
Update spelitem.kod
Nagath Jan 2, 2015
3c14bf0
Update wand.kod
Nagath Jan 2, 2015
e88f690
Update color.h
Nagath Jan 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
210 changes: 106 additions & 104 deletions clientd3d/client.rc

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions clientd3d/color.c
Expand Up @@ -56,6 +56,7 @@ static char colorinfo[][15] = {
{ "255,255,255"}, /* COLOR_BAR4 */
{ "192,192,192"}, /* COLOR_INVNUMFGD */
{ "0,0,0"}, /* COLOR_INVNUMBGD */
{ "255,80,0"} /* COLOR_ITEM_MAGIC_FG */
};

static char color_section[] = "Colors"; /* Section for colors in INI file */
Expand Down Expand Up @@ -403,20 +404,27 @@ HBRUSH DialogCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type)
* GetItemListColor: Get given color id # for given owner-drawn list box.
* (Inventory has different colors than popup dialog lists)
* Doesn't return color itself so that caller can use id to call GetBrush.
* Now colors magic items; any future item colors should be added here.
*/
WORD GetItemListColor(HWND hwnd, int type)
WORD GetItemListColor(HWND hwnd, int type, int flags)
{
switch(type)
if ((flags != NULL) && (GetItemFlags(flags) == (OF_ITEM_MAGIC | OF_GETTABLE)))
return COLOR_ITEM_MAGIC_FG;
else
{
case UNSEL_FGD:
return COLOR_LISTFGD;
case UNSEL_BGD:
return COLOR_LISTBGD;
case SEL_FGD:
return COLOR_LISTSELFGD;
case SEL_BGD:
return COLOR_LISTSELBGD;
switch(type)
{
case UNSEL_FGD:
return COLOR_LISTFGD;
case UNSEL_BGD:
return COLOR_LISTBGD;
case SEL_FGD:
return COLOR_LISTSELFGD;
case SEL_BGD:
return COLOR_LISTSELBGD;
}
}

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion clientd3d/color.h
Expand Up @@ -38,6 +38,7 @@ enum {
COLOR_BAR4, /* Bar graph color #4 (numbers in graphs) */
COLOR_INVNUMFGD, /* Inventory number foreground */
COLOR_INVNUMBGD, /* Inventory number background */
COLOR_ITEM_MAGIC_FG, /* Color for magic weapons in lists*/
MAXCOLORS,
};

Expand All @@ -61,6 +62,6 @@ void ColorsRestoreDefaults(void);
M59EXPORT HBRUSH DialogCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type);
HBRUSH MainCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type);

WORD GetItemListColor(HWND hwnd, int type);
WORD GetItemListColor(HWND hwnd, int type, int flags);

#endif /* #ifndef _COLOR_H */
25 changes: 19 additions & 6 deletions clientd3d/ownerdrw.c
Expand Up @@ -345,18 +345,31 @@ void DrawOwnerListItem(const DRAWITEMSTRUCT *lpdis, Bool selected, Bool combo)
SetBkMode(lpdis->hDC, OPAQUE);
obj = (object_node*)lpdis->itemData;

hColorBg = GetBrush(GetItemListColor(lpdis->hwndItem, (selected? SEL_BGD : UNSEL_BGD)));
hColorBg = GetBrush(GetItemListColor(lpdis->hwndItem, (selected? SEL_BGD : UNSEL_BGD), NULL));
if ((style & OD_ONLYSEL) && (style & (OD_DRAWOBJ | OD_DRAWICON)))
hColorBg = GetBrush(GetItemListColor(lpdis->hwndItem, UNSEL_BGD));
hColorBg = GetBrush(GetItemListColor(lpdis->hwndItem, UNSEL_BGD, NULL));

FillRect(lpdis->hDC, &lpdis->rcItem, hColorBg);

SetBkMode(lpdis->hDC, TRANSPARENT);
crColorText = GetColor(GetItemListColor(lpdis->hwndItem, (selected? SEL_FGD : UNSEL_FGD)));

/* Send object flags for objects with icons in lists for coloring magic weapons.
Character select screen causes a client crash because the character name is
obj; this statement causes NULL to be sent in that case */
if (style & (OD_DRAWOBJ | OD_DRAWICON))
{
crColorText = GetColor(GetItemListColor(lpdis->hwndItem, (selected? SEL_FGD : UNSEL_FGD), obj->flags));
}
else
{
crColorText = GetColor(GetItemListColor(lpdis->hwndItem, (selected? SEL_FGD : UNSEL_FGD), NULL));
}

if ((style & OD_ONLYSEL) && (style & (OD_DRAWOBJ | OD_DRAWICON)))
crColorText = GetColor(GetItemListColor(lpdis->hwndItem, UNSEL_FGD));
crColorText = GetColor(GetItemListColor(lpdis->hwndItem, UNSEL_FGD, obj->flags));


if (lpdis->itemState & ODS_DISABLED)
crColorText = GetSysColor(COLOR_GRAYTEXT);
crColorText = GetSysColor(COLOR_GRAYTEXT);

if (style & OD_DRAWOBJ)
{
Expand Down
3 changes: 2 additions & 1 deletion clientd3d/resource.h
Expand Up @@ -449,13 +449,14 @@
#define ID_OPTIONS_FONT_MAP_TEXT 3510
#define ID_HELP_REQUEST_CS 3511
#define IDM_DRAW_MAP 3512
#define ID_COLOR_MAGIC 3513

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 187
#define _APS_NEXT_COMMAND_VALUE 3513
#define _APS_NEXT_COMMAND_VALUE 3514
#define _APS_NEXT_CONTROL_VALUE 1206
#define _APS_NEXT_SYMED_VALUE 105
#endif
Expand Down
3 changes: 3 additions & 0 deletions clientd3d/winmenu.c
Expand Up @@ -205,6 +205,9 @@ void MenuCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
case ID_COLOR_LISTSEL:
UserSelectColors(COLOR_LISTSELFGD, COLOR_LISTSELBGD);
break;
case ID_COLOR_MAGIC:
UserSelectColor(COLOR_ITEM_MAGIC_FG);
break;
case ID_COLOR_HIGHLIGHT:
UserSelectColor(COLOR_HIGHLITE);
break;
Expand Down
2 changes: 2 additions & 0 deletions include/proto.h
Expand Up @@ -357,6 +357,7 @@ enum {
#define OF_GETTABLE 0x00000010 // Set if player can try to pick up object
#define OF_CONTAINER 0x00000020 // Set if player can put objects inside this one
#define OF_NOEXAMINE 0x00000040 // Set if player CAN'T examine object
#define OF_ITEM_MAGIC 0x00000080 // Set for magic item to color in lists
#define OF_OFFERABLE 0x00000200 // Set if object can be offered to
#define OF_BUYABLE 0x00000400 // Set if object can be bought from
#define OF_ACTIVATABLE 0x00000800 // Set if object can be activated
Expand Down Expand Up @@ -406,6 +407,7 @@ enum {
#define GetPlayerFlags(flags) ((flags) & OF_PLAYER_MASK)
#define GetDrawingEffect(flags) ((flags) & OF_EFFECT_MASK)
#define GetDrawingEffectIndex(flags) (((flags) & OF_EFFECT_MASK) >> 20)
#define GetItemFlags(flags) ((flags))

/* How objects allow or disallow motion onto their square */
enum {
Expand Down
5 changes: 2 additions & 3 deletions kod/include/blakston.khd
Expand Up @@ -58,9 +58,8 @@
CONTAINER_YES = 0x00000020
LOOK_YES = 0
LOOK_NO = 0x00000040

% unused = 0x00000080

ITEM_MAGIC_YES = 0x00000080
ITEM_MAGIC_NO = 0
INVISIBLE_YES = 0x00000100
INVISIBLE_NO = 0
OFFER_YES = 0x00000200
Expand Down
53 changes: 51 additions & 2 deletions kod/object/item.kod
Expand Up @@ -75,8 +75,6 @@ classvars:
% How much this item will help or hinder spell usage.
viSpell_modifier = 0

viObject_flags = GETTABLE_YES

vrIcon_male = $
vrIcon_female = $
vrLeftArm_male = $
Expand All @@ -100,6 +98,7 @@ classvars:

properties:

viObject_flags = GETTABLE_YES
piHits_init = 0
piHits = 0

Expand Down Expand Up @@ -1695,5 +1694,55 @@ messages:
return FALSE;
}

AddMagicFlag()
{
if viObject_flags <> (GETTABLE_YES | ITEM_MAGIC_YES)
{
viObject_flags = viObject_flags | ITEM_MAGIC_YES;
}

if poOwner <> $
AND IsClass(poOwner,&Player)
{
Send(poOwner,@SomethingChanged,#what=self);
}

return;
}

RemoveMagicFlag()
{
local i, iNum, oItemAtt;

for i in plItem_attributes
{
iNum = Send(self,@GetNumFromCompound,#compound=First(i));
oItemAtt = Send(SYS,@FindItemAttByNum,#num=iNum);

if Send(oItemAtt,@IsMagicalEffect)
{
viObject_flags = viObject_flags | ITEM_MAGIC_YES;

if poOwner <> $
AND IsClass(poOwner,&Player)
{
Send(poOwner,@SomethingChanged,#what=self);
}

return;
}
}

viObject_flags = viObject_flags & ~ITEM_MAGIC_YES;

if poOwner <> $
AND IsClass(poOwner,&Player)
{
Send(poOwner,@SomethingChanged,#what=self);
}

return;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 changes: 2 additions & 2 deletions kod/object/item/passitem/minigame.kod
Expand Up @@ -55,8 +55,6 @@ classvars:

vrModule = $

viObject_flags = ACTIVATE_YES | GETTABLE_YES

viMaxPlayers = 2 % Maximum number of people who can play the game at once

viUse_type = ITEM_SINGLE_USE % So "use" command will work with it
Expand All @@ -69,6 +67,8 @@ properties:
plObservers = $ % People who should be informed of game events (doesn't include players)
psState = $ % Current state of game, stored as a string

viObject_flags = ACTIVATE_YES | GETTABLE_YES

messages:

constructor()
Expand Down
1 change: 0 additions & 1 deletion kod/object/item/passitem/spelitem.kod
Expand Up @@ -53,7 +53,6 @@ classvars:

viUse_type = ITEM_SINGLE_USE

viObject_flags = APPLY_YES | GETTABLE_YES
vrIcon = Spellitem_icon_rsc
vrDesc = Spellitem_desc_rsc

Expand Down
2 changes: 2 additions & 0 deletions kod/object/item/passitem/spelitem/wand.kod
Expand Up @@ -52,6 +52,8 @@ properties:

% Set to negative so it doesn't expire naturally.
piGoBadTime = -1

viObject_flags = APPLY_YES | GETTABLE_YES

messages:

Expand Down
46 changes: 43 additions & 3 deletions kod/object/item/passitem/weapon.kod
Expand Up @@ -551,7 +551,7 @@ messages:
"(see ReqWeaponAttack above). This is just to catch anything that "
"slips thru the cracks. See ranged.kod for what this does."
{
debug("A non-ranged weapon called @ReqUseAmmo!");
Debug("A non-ranged weapon called @ReqUseAmmo!");

return TRUE;
}
Expand Down Expand Up @@ -879,7 +879,7 @@ messages:
#num=send(self,@GetNumFromCompound,#compound=first(i)));
if oItemAtt = $
{
DEBUG("Illegal ItemAtt in list!");
Debug("Illegal ItemAtt in list!");

continue;
}
Expand All @@ -893,6 +893,46 @@ messages:
return TRUE;
}

ValidateWeaponAttributes(num = 1)
"Deletes any items with more major weapon attributes than num. Default 1."
{
local iNum;

iNum = 0;

if plItem_attributes = $
{
return;
}

if Send(self,@HasAttribute,#itematt=WA_BLINDER)
{
iNum = iNum + 1;
}

if Send(self,@HasAttribute,#itematt=WA_PARALYZER)
{
iNum = iNum + 1;
}

if Send(self,@HasAttribute,#itematt=WA_VAMPER)
{
iNum = iNum + 1;
}

if Send(self,@HasAttribute,#itematt=WA_PURGER)
{
iNum = iNum + 1;
}
if iNum > num
{
Post(self,@Delete);
Debug("Multiple attribute weapon deleted.");
}

return;
}

CanEnchant(oSpell = $)
"Weapons CAN usually be dedicated to Qor, Kraanan or Shal'ille. "
"Exception: weapons that are already enchanted may not be, "
Expand All @@ -918,7 +958,7 @@ messages:
#num=send(self,@GetNumFromCompound,#compound=first(i)));
if oItemAtt = $
{
DEBUG("Illegal ItemAtt in list!");
Debug("Illegal ItemAtt in list!");

continue;
}
Expand Down
14 changes: 13 additions & 1 deletion kod/object/passive/itematt.kod
Expand Up @@ -324,15 +324,22 @@ messages:
}

RemoveFromItem(oItem=$)
"This must be called. In fact, this is what all attribute "
"This must be called. In fact, this is what all attribute "
"removing things should call."
{
local iValue, lData;

lData = send(oItem,@GetAttributeData,#ItemAtt=viItem_Att_Num);

send(self,@RemoveEffects,#oItem=oItem,#lData=lData);
send(oItem,@RemoveAttributeSpecifics,#oItemAtt=self,#ItemAtt=viItem_Att_num);

%% Remove magic item flag for item attributes that add an effect
if Send(self,@IsMagicalEffect)
{
Post(oItem,@RemoveMagicFlag);
}

return;
}

Expand Down Expand Up @@ -582,6 +589,11 @@ messages:

return;
}

IsMagicalEffect()
{
return FALSE;
}


end
Expand Down
5 changes: 5 additions & 0 deletions kod/object/passive/itematt/iabonded.kod
Expand Up @@ -149,5 +149,10 @@ messages:
return;
}

IsMagicalEffect()
{
return TRUE;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 changes: 5 additions & 0 deletions kod/object/passive/itematt/iadurabl.kod
Expand Up @@ -82,5 +82,10 @@ messages:
return;
}

IsMagicalEffect()
{
return TRUE;
}

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%