private void cmdOk_Click(object sender, EventArgs e) { accepted = true; result = (int)tv.SelectedNode.Tag; // int parent = (int)tv.SelectedNode.Parent.Tag; if (tv.SelectedNode.Parent.Tag != null) { int parent = (int)tv.SelectedNode.Parent.Tag; if (result < 0) { long max = result * -1; string text; if (parent == -1) { text = string.Format(language.getAString(language.order.uiSpecifyTheAmountOnce), max); } else { text = string.Format(language.getAString(language.order.uiSpecifyTheAmountPerTurn), max); } userNumberInput ui = new userNumberInput(language.getAString(language.order.SpecifyTheAmount), text, 0, max, language.getAString(language.order.ok), language.getAString(language.order.cancel)); ui.ShowDialog(); if (ui.result < 0) { // cancel resultInd = 0; accepted = false; } else { resultInd = ui.result; } } else { resultInd = (int)tv.SelectedNode.Tag; } result = parent; resultPlayer = (byte)(int)tv.SelectedNode.Parent.Parent.Tag; } if (accepted) { this.Close(); } }
private void miTransfertSlave_Click(object sender, EventArgs e) { userNumberInput uni = new userNumberInput( "Transfert slaves", "How many slaves do you want to transfert? max: " + Form1.game.playerList[ player ].cityList[ city ].slaves.total.ToString(), 1, Form1.game.playerList[ player ].cityList[ city ].slaves.total, "Ok", "Cancel" ); uni.ShowDialog(); if ( uni.result != -1 ) { int[] order = new int[ Form1.game.playerList[ player ].cityNumber ]; int tot = 0; for ( int c = 1; c <= Form1.game.playerList[ player ].cityNumber; c ++ ) if ( !Form1.game.playerList[ player ].cityList[ c ].dead && c != city ) { order[ tot ] = c; tot++; } string[] names = new string[ tot ]; for ( int c = 0; c < names.Length; c++ ) { names[ c ] = Form1.game.playerList[ player ].cityList[ order[ c ] ].name; } userChoice uc = new userChoice( "Transfert slaves", "Please choose where to send the slaves.", names, 0, "Ok", "Cancel" ); uc.ShowDialog(); if ( uc.result != -1 ) { int eta = Form1.game.playerList[ player ].slaves.moveSlave( city, order[ uc.result ], uni.result ); MessageBox.Show( String.Format( "The slaves will be at destination in {0} turns.", eta ), "Slave transfert" ); } } enableButtons(); }
private void cmdOk_Click(object sender, EventArgs e) { accepted = true; result = (int)tv.SelectedNode.Tag; // int parent = (int)tv.SelectedNode.Parent.Tag; if ( tv.SelectedNode.Parent.Tag != null ) { int parent = (int)tv.SelectedNode.Parent.Tag; if ( result < 0 ) { long max = result * -1; string text; if ( parent == -1 ) text = string.Format( language.getAString( language.order.uiSpecifyTheAmountOnce ), max ); else text = string.Format( language.getAString( language.order.uiSpecifyTheAmountPerTurn ), max ); userNumberInput ui = new userNumberInput( language.getAString( language.order.SpecifyTheAmount ), text, 0, max, language.getAString( language.order.ok ), language.getAString( language.order.cancel ) ); ui.ShowDialog(); if ( ui.result < 0 ) { // cancel resultInd = 0; accepted = false; } else { resultInd = ui.result; } } else { resultInd = (int)tv.SelectedNode.Tag; } result = parent; resultPlayer = (byte)(int)tv.SelectedNode.Parent.Parent.Tag; } if ( accepted ) this.Close(); }