Merge pull request #9 from IngenerkaTeamCenter/ArkLightning-patch-2

Сохранение TXLib и картинок в файл
This commit is contained in:
Mikhail Abramov 2018-03-03 10:31:20 +04:00 committed by GitHub
commit 344484e9ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8615 additions and 28 deletions

View file

@ -121,7 +121,7 @@
//
this.PictureBoxBackground.Location = new System.Drawing.Point(17, 160);
this.PictureBoxBackground.Name = "PictureBoxBackground";
this.PictureBoxBackground.Size = new System.Drawing.Size(100, 50);
this.PictureBoxBackground.Size = new System.Drawing.Size(177, 88);
this.PictureBoxBackground.TabIndex = 12;
this.PictureBoxBackground.TabStop = false;
//
@ -173,7 +173,7 @@
this.SaveCharButton.TabIndex = 3;
this.SaveCharButton.Text = "Сохранить персонажа";
this.SaveCharButton.UseVisualStyleBackColor = true;
this.SaveCharButton.Click += new System.EventHandler(this.saveCharButtonClick);
this.SaveCharButton.Click += new System.EventHandler(this.SaveCharButtonClick);
//
// panel3
//
@ -218,7 +218,7 @@
//
// OpenButton
//
this.OpenButton.Location = new System.Drawing.Point(221, 160);
this.OpenButton.Location = new System.Drawing.Point(225, 153);
this.OpenButton.Name = "OpenButton";
this.OpenButton.Size = new System.Drawing.Size(171, 30);
this.OpenButton.TabIndex = 14;
@ -305,6 +305,7 @@
this.TextBoxWall2.Name = "TextBoxWall2";
this.TextBoxWall2.Size = new System.Drawing.Size(100, 20);
this.TextBoxWall2.TabIndex = 3;
this.TextBoxWall2.TextChanged += new System.EventHandler(this.TextBoxWall2_TextChanged);
//
// TextBoxWall1
//

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -23,9 +24,7 @@ namespace WindowsFormsApplication1
public MainForm()
{
InitializeComponent();
ButtonAddChar.Click += button1_Click;
SaveCharButton.Click += saveCharButtonClick;
openFileDialog1.Filter = "Text files(*OpenFileDialog.txt)|*.txt|All files(*.*)|*.*";
saveFileDialog1.Filter = "Text files(*SaveFileDialog.txt)|*.txt|All files(*.*)|*.*";
}
@ -90,42 +89,121 @@ namespace WindowsFormsApplication1
private void file_beginning(string filename)
{
System.IO.File.WriteAllText(filename, "");
System.IO.File.AppendAllText(filename, "#include \"TXLib.h\"" + Environment.NewLine);
System.IO.File.AppendAllText(filename, Environment.NewLine);
System.IO.File.AppendAllText(filename, "int main()" + Environment.NewLine);
System.IO.File.AppendAllText(filename, "{" + Environment.NewLine);
File.WriteAllText(filename, "");
File.AppendAllText(filename, "#include \"TXLib.h\"" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "int main()" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
}
private void file_forser(string filename)
{
System.IO.File.AppendAllText(filename, Environment.NewLine);
System.IO.File.AppendAllText(filename, "txSetColor(TX_WHITE);" + Environment.NewLine);
System.IO.File.AppendAllText(filename, "txSetFillColor(TX_WHITE);" + Environment.NewLine);
System.IO.File.AppendAllText(filename, "txRectangle(0, 0, 800, 600);" + Environment.NewLine);
System.IO.File.AppendAllText(filename, "HDC texture = txLoadImage(\"Pictures\\Personaj.bmp\");" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txSetColor(TX_WHITE);" + Environment.NewLine);
File.AppendAllText(filename, "txSetFillColor(TX_WHITE);" + Environment.NewLine);
File.AppendAllText(filename, "txRectangle(0, 0, 800, 600);" + Environment.NewLine);
File.AppendAllText(filename, "HDC texture = txLoadImage(\"Pictures\\Personaj.bmp\");" + Environment.NewLine);
}
private void file_ending(string filename)
{
System.IO.File.AppendAllText(filename, "return " + SpriteNumberTextBox.Text + "0;" + Environment.NewLine);
File.AppendAllText(filename, "return " + SpriteNumberTextBox.Text + "0;" + Environment.NewLine);
System.IO.File.AppendAllText(filename, "}" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
}
private void saveCharButtonClick(object sender, EventArgs e)
private void SaveCharButtonClick(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = saveFileDialog1.FileName;
file_beginning(filename);
file_forser(filename);
file_ending(filename);
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
MessageBox.Show("Файл сохранен");
//filename.Replace("Вася", "Лох")
file_beginning(filename);
//file_forser(filename);
sinus(filename);
file_ending(filename);
File.Copy("TXLib.h", filename.Replace(Path.GetFileName(filename), "TXLib.h"), true);
string adres_papki = filename.Replace(Path.GetFileName(filename), "Pictures");
if (!Directory.Exists(adres_papki))
{
Directory.CreateDirectory(adres_papki);
}
File.Copy("kartinka.jpg", adres_papki + "\\Personaj.bmp", true);
MessageBox.Show("Файл сохранен");
}
}
private void sinus(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " HDC texture = txLoadImage(\"Pictures\\Personaj.bmp\");" + Environment.NewLine);
File.AppendAllText(filename, " double textureX = 50;" + Environment.NewLine);
File.AppendAllText(filename, " double textureY = 50;" + Environment.NewLine);
File.AppendAllText(filename, " double nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " while (!GetAsyncKeyState(VK_ESCAPE));" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " txSetColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txSetFillColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txRectangle(0, 0, txGetExtentX(), txGetExtentY());" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " textureX++;" + Environment.NewLine);
File.AppendAllText(filename, " textureY = 300 + 150 * sin(textureX / 10);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, " if (nomer_kadra > 2)" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, " txSleep(10);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txDeleteDC(texture);" + Environment.NewLine);
}
private void circle(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txCreateWindow(800, 600)"+ Environment.NewLine);
File.AppendAllText(filename, "HDC texture = txLoadImage(\"Pictures\\Personaj.bmp);" + Environment.NewLine);
File.AppendAllText(filename, "double textureX = 50"+ Environment.NewLine);
File.AppendAllText(filename, "double textureY = 50"+ Environment.NewLine);
File.AppendAllText(filename, "double angle = 0"+ Environment.NewLine);
File.AppendAllText(filename, "double nomer_kadra = 0"+ Environment.NewLine);
File.AppendAllText(filename, "while (!GetAsyncKeyState(VK_ESCAPE))"+ Environment.NewLine);
File.AppendAllText(filename, "{"+ Environment.NewLine);
File.AppendAllText(filename, "txSetColor(TX_RED)"+ Environment.NewLine);
File.AppendAllText(filename, "txSetFillColor(TX_RED)"+ Environment.NewLine);
File.AppendAllText(filename, "txRectangle(0, 0, txGetExtentX(), txGetExtentY())"+ Environment.NewLine);
File.AppendAllText(filename, "angle++"+ Environment.NewLine);
File.AppendAllText(filename, "textureX = 500 + 200 * cos (angle / 10)"+ Environment.NewLine);
File.AppendAllText(filename, "textureY = 300 + 200 * sin (angle / 10)"+ Environment.NewLine);
File.AppendAllText(filename, "txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255))"+ Environment.NewLine);
File.AppendAllText(filename, "nomer_kadra++"+ Environment.NewLine);
File.AppendAllText(filename, "if (nomer_kadra > 2)"+ Environment.NewLine);
File.AppendAllText(filename, "{"+ Environment.NewLine);
File.AppendAllText(filename, "nomer_kadra = 0"+ Environment.NewLine);
File.AppendAllText(filename, "}"+ Environment.NewLine);
File.AppendAllText(filename, "txSleep(10)"+ Environment.NewLine);
File.AppendAllText(filename, "}"+ Environment.NewLine);
File.AppendAllText(filename, "txDeleteDC(texture)"+ Environment.NewLine);
File.AppendAllText(filename, "return 0"+ Environment.NewLine);
File.AppendAllText(filename, "}"+ Environment.NewLine);
}
private void button5_Click(object sender, EventArgs e)
@ -133,7 +211,7 @@ namespace WindowsFormsApplication1
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
string fileText = System.IO.File.ReadAllText(filename);
string fileText =File.ReadAllText(filename);
nazvanieTextBox.Text = fileText;
MessageBox.Show("Файл открыт");
}
@ -163,11 +241,20 @@ namespace WindowsFormsApplication1
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
string fileText = System.IO.File.ReadAllText(filename);
string fileText =File.ReadAllText(filename);
nazvanieTextBox.Text = fileText;
//MessageBox.Show("Файл открыт");
PictureBoxBackground.Image = Image.FromFile("kartinka.jpg");
}
private void button1_Click_1(object sender, EventArgs e)
{
Close();
}
private void TextBoxWall2_TextChanged(object sender, EventArgs e)
{
}
}
}

File diff suppressed because it is too large Load diff