JNR
RPG_icon_descriptors.cpp
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
30 #include "stdafx.h"
31 #include "RPG.h"
32 #include <Core\Core-Level-JR.h>
33 
34 //laElement* uiPotionDescriptor::_pPotionElement = NULL;
35 
36 void uiRPGItemDescriptor::draw_model(laPoint3 pos, laRenderer *pr)
37 {
38  ASSERT(_pItem, "Nil item descriptor.");
39  ASSERT(_pItem->pTSE, "Nil TS element in item descriptor.");
40  ASSERT(_pItem->pTSE->getParent(), "Nil geometry TS element in item descriptor.");
41 
42  pr->transPush();
43  pr->transTranslate(pos);
44  ((laElement*) (_pItem->pTSE->getParent()) )->drawGeometry(pr);
45  pr->transPop();
46 }
47 
48 void uiRPGItemDescriptor::draw_description(laPoint3 pos, laRenderer *pr, laFont* pf){
49 }
50 
51 laPoint3 uiRPGItemDescriptor::description_size(laFont* pf){
52  return laPoint3();
53 }
54 
55 void uiPotionDescriptor::draw_model(laPoint3 pos, laRenderer *pr)
56 {
57  ASSERT(_pItem, "Nil item descriptor.");
58  ASSERT(_pItem->pTSE, "Nil TS element in item descriptor.");
59  ASSERT(_pItem->pTSE->getParent(), "Nil geometry TS element in item descriptor.");
60 
61  pr->styleSet( ((rpgPotion*)_pItem)->color );
62  pr->transPush();
63  pr->transTranslate(pos);
64  ((laElement*) (_pItem->pTSE->getParent()) )->drawGeometry(pr);
65  pr->transPop();
66 }
67 
68 void uiPotionDescriptor::draw_description(laPoint3 pos, laRenderer *pr, laFont* pf)
69 {
70  rpgPotion *pProperties = (rpgPotion*)_pItem;
71 
72  pf->draw( pos, "%s",// (%.0lf/%.0lf sec)",
73  pProperties->strName, pProperties->dDurationReminder, pProperties->dDuration);
74 
75  uiProgress uiPBar;
76 
77  uiPBar.create(pos + laPoint3(0,10), laPoint3(80, 15));
78  uiPBar.setRange(0, pProperties->dDuration*0.100);
79  uiPBar.setValue(pProperties->dDurationReminder*0.100);
80  uiPBar.draw();
81 
82 
83  // Animation tweak for potion-like effects
84  //
85  /*if( pProperties->pAnimatorObj ){
86 
87  laTimer* pt = ::laSystemIntegrator::getEnvironment()->getTimer();
88  pProperties->pAnimatorObj->animate( *(pt) );
89  }*/
90 }
91 
92 uiPotionDescriptor::~uiPotionDescriptor(void) {
93  rpgPotion *pProperties = (rpgPotion*)_pItem;
94 
95  // Animator object is discarded with the icon descriptor
96  // This is used for potion-like effects in attacks
97  //if( pProperties->pAnimatorObj ) delete pProperties->pAnimatorObj;
98  }
99 
100 laPoint3 uiPotionDescriptor::description_size(laFont* pf)
101 {
102  rpgPotion *pProperties = (rpgPotion*)_pItem;
103  char str[256];
104 
105  sprintf(str, "%s",// (%.0lf/%.0lf sec)",
106  pProperties->strName, pProperties->dDurationReminder, pProperties->dDuration);
107 
108  return laPoint3( M_MAX(80, pf->lenght(str) ), 25);
109 }
110 
111 void uiSkillDescriptor::draw_model(laPoint3 pos, laRenderer *pr)
112 {
113  ASSERT(_pSkill, "Nil item descriptor.");
114  ASSERT(_pSkill->getTSEement(), "Nil TS element in item descriptor.");
115 
116  pr->styleSet( laColor(255,255,255) );
117  pr->transPush();
118  pr->transTranslate(pos);
119  ((laElement*) (_pSkill->getTSEement()) )->drawGeometry(pr);
120  pr->transPop();
121 }
122 
123 void uiSkillDescriptor::draw_description(laPoint3 pos, laRenderer *pr, laFont* pf)
124 {
125  ASSERT(_pSkill, "Nil item descriptor.");
126 
127  pf->draw( pos, "%s", _pSkill->desc());
128 
129  pf->ctlAlignH(M_AR);
130  pf->ctlAlignV(M_AB);
131  laPoint3 sz = description_size(pf);
132  pf->ctlSize(10);
133 
134  if( _pSkill->isLearnt() )
135  {
136  pf->draw( pos + sz, "[%d/%d]", _pSkill->getCurrentIndex()+1, _pSkill->getUpgradeCount());
137  }
138  else
139  {
140  pf->draw( pos + sz, "[new skill]");
141  }
142 }
143 
144 laPoint3 uiSkillDescriptor::description_size(laFont* pf)
145 {
146  ASSERT(_pSkill, "Nil item descriptor.");
147 
148  return laPoint3( 150 /*pf->lenght( _pSkill->desc() )*/, 30 );
149 }
Font and Text Drawing.
Definition: laFont.h:41
#define M_AB
Text align bottom.
Base Class for Tileset Elements.
Definition: laElement.h:48
void draw()
Display the window.
Definition: uiProgress.cpp:85
virtual void create(laPoint3 pos, laPoint3 size)
Create new empty window.
Definition: uiProgress.cpp:56
#define M_AR
Text align right.
Potion RPG Properties.
Definition: rpgPotion.h:44
GUI Progress Bar.
Definition: uiProgress.h:39
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98