Skip to content

Commit

Permalink
Merge pull request #13 from gmoromisato/master
Browse files Browse the repository at this point in the history
1.5
  • Loading branch information
gmoromisato committed Jan 6, 2015
2 parents ee315d6 + aa88734 commit efa32ed
Show file tree
Hide file tree
Showing 48 changed files with 1,183 additions and 218 deletions.
6 changes: 6 additions & 0 deletions Transcendence/CDockScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,12 @@ void CDockScreen::ShowPane (const CString &sName)
return;
}

// Update the source list before we initialize

CSpaceObject *pLocation = m_pDisplay->GetSource();
if (pLocation)
pLocation->UpdateArmorItems();

// Initialize the pane based on the pane descriptor

m_CurrentPane.InitPane(this, pNewPane, m_rcPane);
Expand Down
6 changes: 0 additions & 6 deletions Transcendence/CDockScreenList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ void CDockScreenList::OnShowPane (bool bNoListNavigation)
// Handle case where the pane is shown

{
// Update armor items to match the current state (the damaged flag)

CSpaceObject *pLocation = m_pItemListControl->GetSource();
if (pLocation)
pLocation->UpdateArmorItems();

// Update the item list

ShowItem();
Expand Down
6 changes: 0 additions & 6 deletions Transcendence/CDockScreenSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ void CDockScreenSelector::OnShowPane (bool bNoListNavigation)
// Pane is shown

{
// Update armor items to match the current state (the damaged flag)

CSpaceObject *pLocation = m_pControl->GetSource();
if (pLocation)
pLocation->UpdateArmorItems();

// Update the item list

ShowItem();
Expand Down
1 change: 1 addition & 0 deletions Transcendence/CGAreas.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class CGSelectorArea : public AGArea
void CalcRegionRect (const SEntry &Entry, int xCenter, int yCenter, RECT *retrcRect);
void CleanUp (void);
bool FindLayoutForPos (const CVector &vPos, const TArray<bool> &SlotStatus, int *retiIndex = NULL);
bool FindNearestRegion (int xCur, int yCur, EDirections iDir, bool bDiagOnly, int *retiIndex) const;
bool FindRegionInDirection (EDirections iDir, int *retiIndex = NULL) const;
void PaintEmptySlot (CG16bitImage &Dest, const RECT &rcRect, const SEntry &Entry);
void PaintInstalledItem (CG16bitImage &Dest, const RECT &rcRect, const SEntry &Entry);
Expand Down
136 changes: 79 additions & 57 deletions Transcendence/CGSelectorArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,63 +297,15 @@ bool CGSelectorArea::FindLayoutForPos (const CVector &vPos, const TArray<bool> &
return true;
}

bool CGSelectorArea::FindRegionInDirection (EDirections iDir, int *retiIndex) const
bool CGSelectorArea::FindNearestRegion (int xCur, int yCur, EDirections iDir, bool bDiagOnly, int *retiIndex) const

// FindRegionInDirection
// FindNearestRegion
//
// Looks for the region in the specified direction from the currently selected
// region.
//
// Returns TRUE if the region is found.
// Finds the nearest region to the given position in the given direction.

{
int i;

// Get the current position of the selected region. If we have no selection,
// then we take an arbitrary point at the edge of the area.

int xCur;
int yCur;
if (m_iCursor != -1)
{
const SEntry &Entry = m_Regions[m_iCursor];
xCur = Entry.rcRect.left + (RectWidth(Entry.rcRect) / 2);
yCur = Entry.rcRect.top + (RectHeight(Entry.rcRect) / 2);
}
else
{
const RECT &rcRect = GetRect();
switch (iDir)
{
case moveDown:
xCur = rcRect.left + (RectWidth(rcRect) / 2);
yCur = rcRect.top;
break;

case moveLeft:
xCur = rcRect.right;
yCur = rcRect.top + (RectHeight(rcRect) / 2);
break;

case moveRight:
xCur = rcRect.left;
yCur = rcRect.top + (RectHeight(rcRect) / 2);
break;

case moveUp:
xCur = rcRect.left + (RectWidth(rcRect) / 2);
yCur = rcRect.bottom;
break;

default:
ASSERT(false);
return false;
}
}

// Loop over all regions and find the one the is closest to the
// given region.

int iBest = -1;
int xBestDist;
int yBestDist;
Expand All @@ -371,31 +323,35 @@ bool CGSelectorArea::FindRegionInDirection (EDirections iDir, int *retiIndex) co
{
case moveDown:
bCloser = (Entry.rcRect.top > yCur
&& (yDist >= xDist)
&& (!bDiagOnly || (yDist >= xDist))
&& yDist > 0
&& (iBest == -1
|| yDist < yBestDist
|| (yDist == yBestDist && xDist < xBestDist)));
break;

case moveLeft:
bCloser = (Entry.rcRect.left < xCur
&& (xDist >= yDist)
&& (!bDiagOnly || (xDist > yDist))
&& xDist > 0
&& (iBest == -1
|| xDist < xBestDist
|| (xDist == xBestDist && yDist < yBestDist)));
break;

case moveRight:
bCloser = (Entry.rcRect.left > xCur
&& (xDist >= yDist)
&& (!bDiagOnly || (xDist > yDist))
&& xDist > 0
&& (iBest == -1
|| xDist < xBestDist
|| (xDist == xBestDist && yDist < yBestDist)));
break;

case moveUp:
bCloser = (Entry.rcRect.top < yCur
&& (yDist >= xDist)
&& (!bDiagOnly || (yDist >= xDist))
&& yDist > 0
&& (iBest == -1
|| yDist < yBestDist
|| (yDist == yBestDist && xDist < xBestDist)));
Expand All @@ -414,8 +370,6 @@ bool CGSelectorArea::FindRegionInDirection (EDirections iDir, int *retiIndex) co
}
}

// Found?

if (iBest == -1)
return false;

Expand All @@ -425,6 +379,68 @@ bool CGSelectorArea::FindRegionInDirection (EDirections iDir, int *retiIndex) co
return true;
}

bool CGSelectorArea::FindRegionInDirection (EDirections iDir, int *retiIndex) const

// FindRegionInDirection
//
// Looks for the region in the specified direction from the currently selected
// region.
//
// Returns TRUE if the region is found.

{
// Get the current position of the selected region. If we have no selection,
// then we take an arbitrary point at the edge of the area.

int xCur;
int yCur;
if (m_iCursor != -1)
{
const SEntry &Entry = m_Regions[m_iCursor];
xCur = Entry.rcRect.left + (RectWidth(Entry.rcRect) / 2);
yCur = Entry.rcRect.top + (RectHeight(Entry.rcRect) / 2);
}
else
{
const RECT &rcRect = GetRect();
switch (iDir)
{
case moveDown:
xCur = rcRect.left + (RectWidth(rcRect) / 2);
yCur = rcRect.top;
break;

case moveLeft:
xCur = rcRect.right;
yCur = rcRect.top + (RectHeight(rcRect) / 2);
break;

case moveRight:
xCur = rcRect.left;
yCur = rcRect.top + (RectHeight(rcRect) / 2);
break;

case moveUp:
xCur = rcRect.left + (RectWidth(rcRect) / 2);
yCur = rcRect.bottom;
break;

default:
ASSERT(false);
return false;
}
}

// Look for a region in the given direction, restricting to diagonal.

if (FindNearestRegion(xCur, yCur, iDir, true, retiIndex))
return true;

// If not found, then don't restrict.

return FindNearestRegion(xCur, yCur, iDir, false, retiIndex);
}

ICCItem *CGSelectorArea::GetEntryAtCursor (void)

// GetEntryAtCursor
Expand Down Expand Up @@ -515,7 +531,13 @@ const CItem &CGSelectorArea::GetItemAtCursor (void)
switch (Entry.iType)
{
case typeInstalledItem:
{
// Clear the cache so we get the latest item from the source
// (so that we get updated damage flags, for example).

Entry.pItemCtx->ClearItemCache();
return Entry.pItemCtx->GetItem();
}

default:
return CItem::NullItem();
Expand Down
2 changes: 2 additions & 0 deletions Transcendence/DockScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class IDockScreenDisplay
inline CItemListManipulator &GetItemListManipulator (void) { return OnGetItemListManipulator(); }
inline int GetListCursor (void) { return OnGetListCursor(); }
inline IListData *GetListData (void) { return OnGetListData(); }
inline CSpaceObject *GetSource (void) { return OnGetSource(); }
inline EResults HandleAction (DWORD dwTag, DWORD dwData) { return OnHandleAction(dwTag, dwData); }
inline EResults HandleKeyDown (int iVirtKey) { return OnHandleKeyDown(iVirtKey); }
ALERROR Init (SInitCtx &Ctx, CString *retsError);
Expand All @@ -64,6 +65,7 @@ class IDockScreenDisplay
virtual CItemListManipulator &OnGetItemListManipulator (void) { return g_DummyItemListManipulator; }
virtual int OnGetListCursor (void) { return -1; }
virtual IListData *OnGetListData (void) { return NULL; }
virtual CSpaceObject *OnGetSource (void) { return NULL; }
virtual EResults OnHandleAction (DWORD dwTag, DWORD dwData) { return resultNone; }
virtual EResults OnHandleKeyDown (int iVirtKey) { return resultNone; }
virtual ALERROR OnInit (SInitCtx &Ctx, CString *retsError) { return NOERROR; }
Expand Down
2 changes: 2 additions & 0 deletions Transcendence/DockScreenDisplayImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CDockScreenList : public IDockScreenDisplay
virtual CItemListManipulator &OnGetItemListManipulator (void) { return m_pItemListControl->GetItemListManipulator(); }
virtual int OnGetListCursor (void) { return m_pItemListControl->GetCursor(); }
virtual IListData *OnGetListData (void) { return m_pItemListControl->GetList(); }
virtual CSpaceObject *OnGetSource (void) { return m_pItemListControl->GetSource(); }
virtual EResults OnHandleAction (DWORD dwTag, DWORD dwData);
virtual EResults OnHandleKeyDown (int iVirtKey);
virtual ALERROR OnInit (SInitCtx &Ctx, CString *retsError);
Expand Down Expand Up @@ -96,6 +97,7 @@ class CDockScreenSelector : public IDockScreenDisplay
virtual bool OnGetDefaultBackgroundObj (CSpaceObject **retpObj);
virtual int OnGetListCursor (void) { return m_pControl->GetCursor(); }
virtual IListData *OnGetListData (void) { return m_pControl->GetList(); }
virtual CSpaceObject *OnGetSource (void) { return m_pControl->GetSource(); }
virtual EResults OnHandleAction (DWORD dwTag, DWORD dwData);
virtual EResults OnHandleKeyDown (int iVirtKey);
virtual ALERROR OnInit (SInitCtx &Ctx, CString *retsError);
Expand Down
84 changes: 47 additions & 37 deletions Transcendence/Game/Source/CommonwealthMilitia.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
explosionType= "&vtThermoExplosion1;"
ejectaType= "&vtWreckEjecta;"

attributes= "commonwealth, commonwealthCustoms, commonMilitary, fleetDelivery, friendly, human, majorStation, primary, populated"
attributes= "commonwealth, commonwealthArmory, commonwealthCustoms, commonMilitary, fleetDelivery, friendly, human, majorStation, primary, populated"
levelFrequency= "---cc ur--- ----- ----- -----"
locationCriteria= "+planetary"
enemyExclusionRadius="75"
Expand Down Expand Up @@ -662,6 +662,49 @@
theList
)
</GetGlobalAchievements>

<GetGlobalPlayerPriceAdj>
(block (rank)
(setq rank (objGetData gPlayerShip "militiaRank"))

(switch
; Only at Armory

(not (objHasAttribute aProviderObj 'commonwealthArmory))
Nil

; Must have rank, or nothing available

(leq rank 0)
-1

; Some items only available to majors

(or (eq (itmGetType gItem) &itXM900Missile;)
(eq (itmGetType gItem) &itStarCannon;)
)
(if (gr rank 1)
Nil ; No adjustment
-1 ; Unavailable
)

; Other items are available at a discount depending on level

(eq rank 1)
90

(eq rank 2)
75

(eq rank 3)
55

; No adjustment

Nil
)
)
</GetGlobalPlayerPriceAdj>

<OnCreate>
(block (gate gateList count)
Expand Down Expand Up @@ -1039,42 +1082,9 @@
<Armory desc="You are in the station's armory shop. You may buy weapons and armor to equip your ship.">
<Actions>
<Action name="Buy Items" default="1" key="B">
(scrShowBuyScreen
(lambda (thisItem)
(block (rank)
(setq rank (objGetData gPlayerShip "militiaRank"))
(switch
(or (itmIsDamaged thisItem) (itmIsInstalled thisItem))
Nil

(itmHasModifier thisItem 'Illegal)
Nil

; Some items only available to Majors
(or (eq (itmGetType thisItem) &itXM900Missile;)
(eq (itmGetType thisItem) &itStarCannon;)
)
(if (gr rank 1)
(itmGetPrice thisItem 'credit)
Nil
)

; Other items are available at a discount depending on level
(eq rank 1)
(divide (multiply (itmGetPrice thisItem 'credit) 90) 100)

(eq rank 2)
(divide (multiply (itmGetPrice thisItem 'credit) 75) 100)

(eq rank 3)
(divide (multiply (itmGetPrice thisItem 'credit) 55) 100)

; item not available
Nil
)
)
)
)
(scrShowScreen gScreen &dsRPGCommoditiesExchangeBuy; {
checkMilitaryID: True
})
</Action>

<Action name="Leave" cancel="1" key="L">
Expand Down
Loading

0 comments on commit efa32ed

Please sign in to comment.