Ana kodda Stats adında bir butonum var ve tıklanınca aşağıdaki fonksiyon çağrılıyor.
Şu an cihazım güncelleniyor, güncellenmiş halini denemedim.
void ShowStats; { GetTimer.Enabled = False; //Oyundaki zamanlayıcı ilerlemesin diye durduruyorum //RouteUnit('Stats'); // Bu olduğu zaman direkt olarak proje açılmıyor Clomosy.RunUnit('Stats'); //Bu olduğu zaman sadece butona basılınca zamanlayıcı durduruluyor yeni unit açılmıyor
}
Unit kodu (ismi Stats):
uses clMainScript;
var statsForm : TclGameForm; testChart : TClChart; simpleJSONStr : String; int profit : Integer; profitLbl : TClProLabel; itemsSoldMemo, itemsPurchasedMemo : TCLMemo; bottomPanel : TclProPanel; index : Integer; backButton : TClProButton;
void BackToShop; { statsForm.btnGoBackClick(self); clMainScript.GetTimer.Enabled = True; }
{ statsForm = TclGameForm.Create(self); statsForm.SetFormColor('#d4bb90', '', clGNone); testChart = statsForm.AddNewChart(statsForm,'testChart','Samsoong'); simpleJSONStr = '[{ "Type": "Income","Value": ' + IntToStr(clMainScript.dailyIncome) + ',"color":"clGreen"},{"Type" : "Outcome","Value": ' + IntToStr(clMainScript.dailyOutcome) +',"color":"clRed"}]'; testChart.Align = alCenter; testChart.Charttype = clCPie; testChart.XAxisText = 'Type'; testChart.ChartItemText = 'Legend'; testChart.ChartItemsValue = 'Value'; testChart.ChartTitle = 'Day ' + IntToStr(clMainScript.dayCounter) + ' Statistics'; testChart.clLoadDataFromJSONStr(simpleJSONStr); profit = (clMainScript.dailyIncome - clMainScript.dailyOutcome); profitLbl = statsForm.AddNewProLabel(statsForm, 'profitLbl', ''); profitLbl.Align = alMostTop; profitLbl.Text = 'Daily Profit:' + IntToStr(profit); clComponent.SetupComponent(profitLbl,'{ "TextBold":"yes","TextSize":16, "TextHorizontalAlign":"center" ,"MarginLeft":5}');
bottomPanel=statsForm.AddNewProPanel(statsForm, 'bottomPanel'); bottomPanel.Height=statsForm.clheight*40/100; bottomPanel.Align=alBottom;
itemsSoldMemo = statsForm.AddNewMemo(bottomPanel,'itemsSoldMemo', 'Daily Sold Item(s):'); itemsSoldMemo.Align = alLeft; itemsSoldMemo.Margins.Left = 130; itemsSoldMemo.Height = 1; itemsSoldMemo.Width = 140; itemsSoldMemo.Margins.Top = 30; itemsSoldMemo.Margins.Bottom = 30; itemsSoldMemo.ReadOnly = True; itemsSoldMemo.TextSettings.WordWrap = True; itemsPurchasedMemo = statsForm.AddNewMemo(bottomPanel,'itemsPurchasedMemo', 'Daily Purchased Item(s):'); itemsPurchasedMemo.Align = alRight; itemsPurchasedMemo.Margins.Right= 130; itemsPurchasedMemo.Height = 1; itemsPurchasedMemo.Width = 140; itemsPurchasedMemo.Margins.Top = 30; itemsPurchasedMemo.Margins.Bottom = 30; itemsPurchasedMemo.ReadOnly = True; itemsPurchasedMemo.TextSettings.WordWrap = True;
for(index = 0 to (clMainScript.dailySoldItems.Count - 1)) { itemsSoldMemo.Lines.Add(clMainScript.dailySoldItems.GetItem(index)); } for(index = 0 to (clMainScript.dailyPurchasedItems.Count - 1)) { itemsPurchasedMemo.Lines.Add(clMainScript.dailyPurchasedItems.GetItem(index)); } backButton = statsForm.AddNewProButton(statsForm, 'statsForm', 'BACK'); clComponent.SetupComponent(backButton,'{"Align" : "Right","MarginBottom":135,"Width" :200,"Height":70}'); statsForm.SetImage(backButton,' https://clomosy.com/demos/foodInformationBox.png" rel="nofollow - https://clomosy.com/demos/foodInformationBox.png '); statsForm.AddNewEvent(backButton,tbeOnClick,'Stats.BackToShop'); statsForm.Run; }
|