📄 approbot.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <IniFiles.hpp>
#define Name_robot "Name"
#define Age_robot "Age"
#define Sex_robot "Sex"
#define CLC_chat "ChatListColor"
#define CFC_chat "ChatFontColor"
#define LC_chat "ListColor"
#define FC_chat "FontColor"
#define UseLocal "UseLocalAddress"
#define UseMator "UseMatorAddress"
#define MatorIP "MatorIPAddress"
#define MatorPore "MatorPoreAddress"
#include "Approbot.h"
#include "mainform.h"
#include "Robotconfig.h"
//---------------------------------------------------------------------------
AnsiString __fastcall TApprobot::SetRobotString()
{
AnsiString dialog;//用来保存要显示的信息;
dialog = "机器人姓名: " + robotname + "\n"
+ "机器人性别:" + robotsex + "\n机器人年龄:" + robotage
+ "\n.......................\n";
dialog = dialog + "聊天记录区背景颜色:" + chatlistcolor +
"\n聊天记录区文字颜色:" + chatfontcolor + "\n发言区背景颜色:"
+ listcolor + "\n发言区文字颜色:" + fontcolor + "\n........................\n";
if(this->muselocal)
dialog = dialog + "使用本地机器人";
else
{
dialog = dialog + "使用远程机器人"
+ "\n远程服务器地址:" + metoraddress
+ "\n服务器端口:" + metorpore;
}
return dialog;
}
//---------------------------------------------------------------------------
void __fastcall TApprobot::RefreshRobot()
{
//在每次程序开始时自动赋给机器人的属性值或当改动机器人的属性时有些没有被赋值的属性自动赋值;
this->robotname = "阿美";
this->robotage = 21;
this->robotsex = "女";
this->chatlistcolor = "clWhite";
this->chatfontcolor = "clBlack";
this->listcolor = "clWhite";
this->fontcolor = "clBlack";
this->uselocal = true;
this->usemetor = false;
this->metoraddress = "192.168.1.9";
this->metorpore = 80;
}
void __fastcall TApprobot::savetoinifiles()
{
AnsiString filepath = ExtractFilePath( Application->ExeName );
filepath = filepath + "Robot.ini";
TIniFile *robotdia = new TIniFile( filepath);
robotdia->WriteString( "Robot", Name_robot, this->robotname );
robotdia->WriteString( "Robot", Sex_robot, this->robotsex );
robotdia->WriteInteger("Robot", Age_robot, this->robotage );
robotdia->WriteString("Robot", CLC_chat, this->chatlistcolor );
robotdia->WriteString("Robot", CFC_chat, this->chatfontcolor);
robotdia->WriteString("Robot", LC_chat, this->listcolor);
robotdia->WriteString("Robot", FC_chat, this->fontcolor);
robotdia->WriteBool("Robot", UseLocal, this->uselocal);
robotdia->WriteBool("Robot", UseMator, this->usemetor);
robotdia->WriteString("Robot", MatorIP, this->metoraddress);
robotdia->WriteInteger("Robot", MatorPore, this->metorpore);
delete robotdia;
}
void __fastcall TApprobot::loadfrominifiles()
{
AnsiString filepath = ExtractFilePath( Application->ExeName );
filepath = filepath + "Robot.ini";
TIniFile *inifile = new TIniFile(filepath);
this->robotname = inifile->ReadString("Robot", Name_robot,"Dream Star Boy");
this->robotage = inifile->ReadInteger("Robot", Age_robot, 21);
this->robotsex = inifile->ReadString("Robot", Sex_robot, "男");
this->chatlistcolor = inifile->ReadString("Robot", CLC_chat, "");
this->chatfontcolor = inifile->ReadString("Robot", CFC_chat, "");
this->fontcolor = inifile->ReadString("Robot", FC_chat,"");
this->listcolor = inifile->ReadString("Robot", LC_chat, "");
this->uselocal = inifile->ReadBool("Robot", UseLocal, true);
this->usemetor = inifile->ReadBool("Robot", UseMator, false);
this->metoraddress = inifile->ReadString("Robot", MatorIP,"192.168.1.9");
this->metorpore = inifile->ReadInteger("Robot", MatorPore,8080);
{
Form1->aRobot->Name = this->robotname;
Form1->aRobot->Age = this->robotage;
if(this->robotsex == "男" )
Form1->aRobot->Sex = ChatRobot::Male;
else
if(this->robotsex == "女")
Form1->aRobot->Sex = ChatRobot::Female;
else
Form1->aRobot->Sex = -1;
/*Form1->mbChatList->Color = this->chatlistcolor;
Form1->mbChatList->Font->Color = this->chatfontcolor;
Form1->mbMyInfo->Color = this->listcolor;
Form1->mbMyInfo->Font->Color = this->fontcolor;
*/
//Form1->aRobot->Introduce();
}
delete inifile;
}
__fastcall TApprobot::TApprobot()
{
//RefreshRobot(); //在对象初始化时赋初值;
//loadfrominifiles();
}
//---------------------------------------------------------------------------
#pragma package(smart_init)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -