1 /* $Id: PracticeSelectView.cpp,v 1.6 2003/01/16 16:27:51 nan Exp $ */
2 
3 // Copyright (C) 2001, 2002, 2003  $B?@Fn(B $B5H9((B(Kanna Yoshihiro)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19 #include "ttinc.h"
20 #include "PracticeSelectView.h"
21 #include "PracticeSelect.h"
22 #include "LoadImage.h"
23 #include "BaseView.h"
24 #include "RCFile.h"
25 
26 extern RCFile *theRC;
27 
PracticeSelectView()28 PracticeSelectView::PracticeSelectView() : PlayerSelectView() {
29 }
30 
~PracticeSelectView()31 PracticeSelectView::~PracticeSelectView() {
32 }
33 
34 bool
Redraw()35 PracticeSelectView::Redraw() {
36   int i;
37 
38   glColor4f( 0.0, 0.0, 0.0, 0.0 );
39 
40   if ( m_playerSelect->GetSelected() > 0 ) {
41     int player;
42 
43     player = m_playerSelect->GetPlayerNum();
44 
45     glPushMatrix();
46     if ( m_playerSelect->GetSelected() < 100 ) {
47       if ( theRC->gmode != GMODE_SIMPLE )
48 	glEnable(GL_TEXTURE_2D);
49       glTranslatef( -1.0, -1.0F+0.01F*m_playerSelect->GetSelected(), 1.0F );
50       glRotatef( m_playerSelect->GetSelected()*360.0F/100, 0.0F, 0.0F, 1.0F );
51     } else {
52       glEnable(GL_TEXTURE_2D);
53       glTranslatef( -0.01F*100, -1.0F+0.01F*100, 1.0F );
54     }
55 
56     glBindTexture(GL_TEXTURE_2D, m_textures[player] );
57     glBegin(GL_QUADS);
58     glTexCoord2f(0.0F, 1.0F); glVertex3f(-0.40F, 0.0F, -0.56F);
59     glTexCoord2f(0.0F, 0.0F); glVertex3f(-0.40F, 0.0F,  0.56F);
60     glTexCoord2f(1.0F, 0.0F); glVertex3f( 0.40F, 0.0F,  0.56F);
61     glTexCoord2f(1.0F, 1.0F); glVertex3f( 0.40F, 0.0F, -0.56F);
62     glEnd();
63     glPopMatrix();
64   } else {
65     if ( theRC->gmode != GMODE_SIMPLE ||
66 	 (m_playerSelect->GetRotate()%360)%(360/PLAYERS) == 0 )
67       glEnable(GL_TEXTURE_2D);
68 
69     for ( i = 0 ; i < PLAYERS ; i++ ){
70       glPushMatrix();
71         glTranslatef( -1.0, -0.0, 0.0 );
72         glRotatef( m_playerSelect->GetRotate()-i*360.0F/PLAYERS,
73 		   0.0F, 0.0F, 1.0F );
74 	glBindTexture(GL_TEXTURE_2D, m_textures[i] );
75 	glBegin(GL_QUADS);
76 	glTexCoord2f(0.0F, 1.0F); glVertex3f(-0.40F, -1.0F, 1.0F-0.56F);
77 	glTexCoord2f(0.0F, 0.0F); glVertex3f(-0.40F, -1.0F, 1.0F+0.56F);
78 	glTexCoord2f(1.0F, 0.0F); glVertex3f( 0.40F, -1.0F, 1.0F+0.56F);
79 	glTexCoord2f(1.0F, 1.0F); glVertex3f( 0.40F, -1.0F, 1.0F-0.56F);
80 	glEnd();
81       glPopMatrix();
82     }
83   }
84 
85   glDisable(GL_TEXTURE_2D);
86 
87   long selected = ((PracticeSelect *)m_playerSelect)->GetOpponentSelected();
88 
89   if ( selected > 0 ) {
90     int player;
91 
92     player = ((PracticeSelect *)m_playerSelect)->GetOpponentNum();
93 
94     glPushMatrix();
95     if ( selected < 100 ) {
96       if ( theRC->gmode != GMODE_SIMPLE )
97 	glEnable(GL_TEXTURE_2D);
98       glTranslatef( 1.0F, -1.0F+0.01F*selected, 1.0F );
99       glRotatef( selected*360.0F/100, 0.0F, 0.0F, 1.0F );
100     } else {
101       glEnable(GL_TEXTURE_2D);
102       glTranslatef( 0.01F*100, -1.0F+0.01F*100, 1.0F );
103     }
104 
105     glBindTexture(GL_TEXTURE_2D, m_textures[player] );
106     glBegin(GL_QUADS);
107     glTexCoord2f(0.0F, 1.0F); glVertex3f(-0.40F, 0.0F, -0.56F);
108     glTexCoord2f(0.0F, 0.0F); glVertex3f(-0.40F, 0.0F,  0.56F);
109     glTexCoord2f(1.0F, 0.0F); glVertex3f( 0.40F, 0.0F,  0.56F);
110     glTexCoord2f(1.0F, 1.0F); glVertex3f( 0.40F, 0.0F, -0.56F);
111     glEnd();
112     glPopMatrix();
113   } else {
114     long rotate = ((PracticeSelect *)m_playerSelect)->GetOpponentRotate();
115 
116     if ( theRC->gmode != GMODE_SIMPLE || (rotate%360)%(360/PLAYERS) == 0 )
117       glEnable(GL_TEXTURE_2D);
118 
119     for ( i = 0 ; i < PLAYERS ; i++ ){
120       glPushMatrix();
121         glTranslatef( 1.0, -0.0, 0.0 );
122 	glRotatef( rotate-i*360.0F/PLAYERS, 0.0F, 0.0F, 1.0F );
123 	glBindTexture(GL_TEXTURE_2D, m_textures[i] );
124 	glBegin(GL_QUADS);
125         if ( m_playerSelect->GetSelected() < 100 ) {
126 	  glTexCoord2f(0.0F, 1.0F); glVertex3f(-0.40F, -0.5F, 1.0F-0.56F);
127 	  glTexCoord2f(0.0F, 0.0F); glVertex3f(-0.40F, -0.5F, 1.0F+0.56F);
128 	  glTexCoord2f(1.0F, 0.0F); glVertex3f( 0.40F, -0.5F, 1.0F+0.56F);
129 	  glTexCoord2f(1.0F, 1.0F); glVertex3f( 0.40F, -0.5F, 1.0F-0.56F);
130 	} else {
131 	  glTexCoord2f(0.0F, 1.0F); glVertex3f(-0.40F, -1.0F, 1.0F-0.56F);
132 	  glTexCoord2f(0.0F, 0.0F); glVertex3f(-0.40F, -1.0F, 1.0F+0.56F);
133 	  glTexCoord2f(1.0F, 0.0F); glVertex3f( 0.40F, -1.0F, 1.0F+0.56F);
134 	  glTexCoord2f(1.0F, 1.0F); glVertex3f( 0.40F, -1.0F, 1.0F-0.56F);
135 	}
136 	glEnd();
137       glPopMatrix();
138     }
139   }
140 
141   glColor4f( 1.0F, 1.0F, 1.0F, 0.0F );
142 
143   glPushMatrix();
144   glMatrixMode(GL_PROJECTION);
145   glPushMatrix();
146   glLoadIdentity();
147   gluOrtho2D( 0.0F, (GLfloat)BaseView::GetWinWidth(),
148 	      0.0F, (GLfloat)BaseView::GetWinHeight() );
149   glMatrixMode(GL_MODELVIEW);
150   glLoadIdentity();
151 
152   glRasterPos2i( 200, 100 );
153   glBitmap( 400, 70, 0.0F, 0.0F, 0.0F, 0, m_selectPlayer->GetImage() );
154 
155   glMatrixMode(GL_PROJECTION);
156   glPopMatrix();
157   glMatrixMode(GL_MODELVIEW);
158   glPopMatrix();
159 
160   glDisable(GL_TEXTURE_2D);
161 
162   return true;
163 }
164 
165 bool
RedrawAlpha()166 PracticeSelectView::RedrawAlpha() {
167   return true;
168 }
169