summaryrefslogtreecommitdiff
path: root/src/Plugins/Common/StdShopInfoDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugins/Common/StdShopInfoDialog.cpp')
-rw-r--r--src/Plugins/Common/StdShopInfoDialog.cpp187
1 files changed, 187 insertions, 0 deletions
diff --git a/src/Plugins/Common/StdShopInfoDialog.cpp b/src/Plugins/Common/StdShopInfoDialog.cpp
index a3ee04d..43e7283 100644
--- a/src/Plugins/Common/StdShopInfoDialog.cpp
+++ b/src/Plugins/Common/StdShopInfoDialog.cpp
@@ -1,7 +1,194 @@
#include "StdShopInfoDialog.h"
+#include "T2DateTime.h"
+#include "T2DlgItemArrows.h"
+#include "T2DlgItemEdit.h"
+#include "T2DlgItemMerchandiseField.h"
+#include "T2Tenant.h"
+#include "T2TenantMemberDef.h"
+#include "T2TenantMemberTableDef.h"
+#include "T2TowerDoc.h"
+#include "T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+
+StdShopInfoDialog::StdShopInfoDialog(T2Tenant *inTenant)
+ : StdTenantInfoDialog(inTenant)
+ , mNumMerchandise(0)
+{
+}
+
+/*virtual*/ StdShopInfoDialog::~StdShopInfoDialog() {
+}
+
+/*virtual*/ void StdShopInfoDialog::GenerateComments() {
+ StdTenantInfoDialog::GenerateComments();
+
+ T2DateTime *now = GetDocument()->GetNow();
+#line 40
+ _ASSERT(now != NULL);
+
+ if (GetTenant()->IsOpen()) {
+ // EN: There aren't many customers.
+ int id = 18;
+
+ switch (GetTenant()->CalcEstimateColor()) {
+ case 9:
+ // EN: There aren't many customers.
+ id = 18;
+ break;
+ case 14:
+ // EN: There are a few customers.
+ id = 19;
+ break;
+ case 12:
+ // EN: Business is booming.
+ id = 20;
+ break;
+ }
+
+ AppendComment(id);
+
+ if (id == 20 && now->IsHoliday(GetDocument())) {
+ // EN: There are many customers due to the weekend.
+ AppendComment(21);
+ }
+
+ if (id == 18 && GetDocument()->GetWorldDef()->IsRainyDay(now)) {
+ // EN: There are fewer customers because its a rainy day.
+ AppendComment(22);
+ }
+ } else {
+ if (GetTenant()->GetStatus() == kTenantStatus11) {
+ // EN: Will be opened tomorrow.
+ AppendComment(23);
+ }
+ }
+}
+
+/*virtual*/ void StdShopInfoDialog::OnT2Create() {
+ StdTenantInfoDialog::OnT2Create();
+
+ if (!GetTenant()->IsFire())
+ InitNormal();
+ else
+ InitFire();
+}
+
+/*virtual*/ void StdShopInfoDialog::OnT2OK() {
+ StdTenantInfoDialog::OnT2OK();
+
+ if (!GetTenant()->IsFire())
+ SaveMerchandise();
+}
+
+void StdShopInfoDialog::InitNormal() {
+ T2TenantMemberTableDef *theTMT = GetTenant()->GetMerchandiseTMT();
+ if (theTMT) {
+ mNumMerchandise = theTMT->GetNumOfElem();
+
+ for (int i = 0; i < 4; i++) {
+ T2TenantMemberDef *theMerchandise = (i < mNumMerchandise) ? theTMT->GetElem(i) : NULL;
+
+ T2DlgItem *text = GetT2DlgItem(8001 + i * 4);
+ if (text && theMerchandise) {
+ CString name;
+ theMerchandise->GetName(name);
+ text->SetDescriptor(name);
+ }
+
+ T2DlgItem *merchandise = GetT2DlgItem(8002 + i * 4);
+ if (merchandise) {
+ if (theMerchandise)
+ merchandise->SetValue(theMerchandise->GetPercent());
+ else
+ merchandise->EnableWindow(false);
+ }
+
+ T2DlgItemArrows *arrows = (T2DlgItemArrows *) GetT2DlgItem(8003 + i * 4);
+ if (arrows) {
+ if (theMerchandise)
+ arrows->SetValue(theMerchandise->GetPercent());
+
+ arrows->SetMinValue(0);
+ arrows->SetMaxValue(100);
+ arrows->ShowWindow(SW_HIDE);
+ }
+ }
+ }
+}
+
+void StdShopInfoDialog::InitFire() {
+ for (int i = 0; i < 4; i++) {
+ T2DlgItem *merchandise = GetT2DlgItem(8002 + i * 4);
+ merchandise->EnableWindow(false);
+
+ T2DlgItemArrows *arrows = (T2DlgItemArrows *) GetT2DlgItem(8003 + i * 4);
+ arrows->ShowWindow(SW_HIDE);
+ }
+}
+
+void StdShopInfoDialog::SaveMerchandise() {
+ if (mNumMerchandise > 0) {
+ int i, array[4];
+
+ for (i = 0; i < 4; i++) {
+ T2DlgItem *theField = GetT2DlgItem(8002 + i * 4);
+ if (theField)
+ array[i] = theField->GetValue();
+ else
+ break;
+ }
+
+ GetTenant()->SetMerchandise(i, array);
+ }
+}
+
+/*virtual*/ BOOL StdShopInfoDialog::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) {
+ BOOL result = false;
+ WORD code = HIWORD(inWParam);
+ WORD itemID = LOWORD(inWParam);
+
+ for (int n = 0; n < 4; n++) {
+ if (itemID == (8003 + n * 4)) {
+ result = true;
+
+ T2DlgItemArrows *arrows = (T2DlgItemArrows *) GetT2DlgItem(8003 + n * 4);
+ T2DlgItemMerchandiseField *field = (T2DlgItemMerchandiseField *) GetT2DlgItem(8002 + n * 4);
+ if (arrows && field) {
+ int change = arrows->GetValue() - field->GetValue();
+ if (change == 0)
+ break;
+
+ for (int next = (n + 1) % mNumMerchandise; next != n; next = (next + 1) % mNumMerchandise) {
+ T2DlgItemArrows *nextArrows = (T2DlgItemArrows *) GetT2DlgItem(8003 + next * 4);
+ T2DlgItemMerchandiseField *nextField = (T2DlgItemMerchandiseField *) GetT2DlgItem(8002 + next * 4);
+
+ if (nextArrows && nextField) {
+ int nextValue = nextField->GetValue();
+ if ((change > 0 && nextValue > 0) || (change < 0 && nextValue < 100)) {
+ nextValue -= change;
+ nextField->SetValue(nextValue);
+ nextArrows->SetValue(nextValue);
+ nextField->Invalidate();
+
+ field->SetValue(arrows->GetValue());
+ field->SelectAll();
+ field->Invalidate();
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ if (!result)
+ result = StdTenantInfoDialog::OnT2DialogCommand(inWParam, inLParam);
+
+ return result;
+}