-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitFormLaberinto.cpp
More file actions
141 lines (107 loc) · 3.95 KB
/
UnitFormLaberinto.cpp
File metadata and controls
141 lines (107 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "UnitFormLaberinto.h"
#include "UnitDatos.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormLaberinto *FormLaberinto;
static int id_equipo;
static double pto_total;
void ActualizarComboBox(void)
{
LeerArchivoTodo();
FormLaberinto->ComboBox_Equipos->Items->Clear();
int i=0;
for(i=0; i<num_equipos; i++)
{
FormLaberinto->ComboBox_Equipos->Items->Add(AnsiString(equipo[i].nombre));
}
}
//---------------------------------------------------------------------------
__fastcall TFormLaberinto::TFormLaberinto(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::Button_ExitClick(TObject *Sender)
{
GuardarArchivoTodo();
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::ComboBox_EquiposChange(TObject *Sender)
{
id_equipo = ComboBox_Equipos->ItemIndex;
LeerArchivoTodo();
Edit_Temp1->Text = equipo[id_equipo].lab_tiempo1;
Edit_Temp2->Text = equipo[id_equipo].lab_tiempo2;
Edit_Temp3->Text = equipo[id_equipo].lab_tiempo3;
Edit_SalComp->Text = equipo[id_equipo].lab_sal_completa;
Edit_SalBox->Text = equipo[id_equipo].lab_boxes;
Edit_SalCompBox->Text = equipo[id_equipo].lab_completa_and_boxes;
Label_PtoTot->Caption = equipo[id_equipo].lab_puntos;
if(equipo[id_equipo].lab_best==1)CheckBoxBest->Checked = True;
else CheckBoxBest->Checked = False;
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::Button_guardarClick(TObject *Sender)
{
equipo[id_equipo].lab_tiempo1 = Edit_Temp1->Text.ToDouble();
equipo[id_equipo].lab_tiempo2 = Edit_Temp2->Text.ToDouble();
equipo[id_equipo].lab_tiempo3 = Edit_Temp3->Text.ToDouble();
equipo[id_equipo].lab_sal_completa = Edit_SalComp->Text.ToInt();
equipo[id_equipo].lab_boxes = Edit_SalBox->Text.ToInt();
equipo[id_equipo].lab_completa_and_boxes = Edit_SalCompBox->Text.ToInt();
if (CheckBoxBest->Checked) equipo[id_equipo].lab_best = 1;
else equipo[id_equipo].lab_best = 0;
equipo[id_equipo].lab_puntos = pto_total;
equipo[id_equipo].SumPuntosTotal();
GuardarArchivoTodo();
ActualizarComboBox();
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::Button_calcClick(TObject *Sender)
{
static int sal_completa, boxes, completa_and_boxes, best, i;
static double tiempo[3], tmax;
double tiempobest = 9999;
tiempo[0]= Edit_Temp1->Text.ToDouble();
tiempo[1] = Edit_Temp2->Text.ToDouble();
tiempo[2] = Edit_Temp3->Text.ToDouble();
for (i = 0; i < 3; i++) {
if(tiempo[i] < tiempobest)
tiempobest = tiempo[i];
}
sal_completa = Edit_SalComp->Text.ToInt();
boxes = Edit_SalBox->Text.ToInt();
completa_and_boxes = Edit_SalCompBox->Text.ToInt();
if (CheckBoxBest->Checked) best = 1;
else best = 0;
tmax = LabeledEditTmax->Text.ToDouble();
pto_total = (60-(60/tmax)*tiempobest)+5*best-3*sal_completa-4*boxes-5*completa_and_boxes; //ESTA MAL!
if (pto_total > 60)
pto_total = 60;
if(pto_total < 0)
pto_total = 0;
Label_PtoTot->Caption = pto_total;
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::FormShow(TObject *Sender)
{
LeerArchivoTodo();
FormLaberinto->ComboBox_Equipos->Items->Clear();
int i=0;
for(i=0; i<num_equipos; i++)
{
FormLaberinto->ComboBox_Equipos->Items->Add(AnsiString(equipo[i].nombre));
}
}
//---------------------------------------------------------------------------
void __fastcall TFormLaberinto::ButtonPtoTotalClick(TObject *Sender)
{
pto_total = LabeledEditPtoTotal->Text.ToDouble();
Label_PtoTot->Caption = LabeledEditPtoTotal->Text.ToDouble();
}
//---------------------------------------------------------------------------