game.h lv.2

// <cgame> -*- C++ -*-

//No Copyright.

//  This is a C++ Library header.

#ifndef game6
#define game6 
#include<windows.h>
#include<iostream>
#include<fstream>
namespace game6
{
/* DO NOT EDIT ! */
#define gFILE_VERSION	"1.0.1.0"
#define gFILE_DESCRIPTION	"Developed using the Dev-C++ IDE"
#define gLEGAL_COPYRIGHT	    "None"
#define gORIGINAL_FILENAME	"cgame"
#define gPRODUCT_VERSION	"1.0.1.0"
long long time(){return ::GetTickCount();}//毫秒级 
long long time(long long init){return ::GetTickCount()-init;}//毫秒级 
void hidew(){ShowWindow(GetConsoleWindow(),SW_HIDE);}
void seenw(){ShowWindow(GetConsoleWindow(),SW_SHOW);}
void goxy(int x, int y){SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),{x,y});}
void hidecur(){
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void movewin(){
RECT rect;
HWND hwnd = GetForegroundWindow();
GetWindowRect(hwnd, &rect);
MoveWindow(GetForegroundWindow(),0,0,0,0,1);
}
void wintop(std::string n)//标题 
{
std::string t = "title ";
t += n;
system(&t[0]);
}
//wincon 
#define FOREGROUND_BLUE 0x1
#define FOREGROUND_GREEN 0x2
#define FOREGROUND_RED 0x4
#define FOREGROUND_INTENSITY 0x8
#define BACKGROUND_BLUE 0x10
#define BACKGROUND_GREEN 0x20
#define BACKGROUND_RED 0x40
#define BACKGROUND_INTENSITY 0x80
//wincon
void color(int a,int b){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a+b*0x10);}
void color(int x){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);}
void top()//将置顶与不置顶来回更换 
{
HWND hWnd = ::GetForegroundWindow();
if (::GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST)::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
else::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
void wsize(short h,short l)//windows size
{
std::string n="mode con cols=",t="";
while(l>0)
{
t+=char(l%10+'0');
l/=10;
}
for(int i=t.size()-1;i>=0;i--)n+=t[i];
n+=" lines=",t="";
while(h>0)
{
t=t+char(h%10+'0');
h/=10;
}
for(int i=t.size()-1;i>=0;i--)n+=t[i];
system(&n[0]);
return;
}
void nomode()//移除快速编辑模式
{
DWORD mode;
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),&mode);
mode&=~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),mode);
return;
}
void hcur()//隐藏光标
{
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible=FALSE;
cursor.dwSize=sizeof(cursor);
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor);
}
void movecur(long long h, long long l){SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),{l-1,h-1});}

void fout(int n, std::string name)//参考饼干369 
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(long long n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(bool n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(char n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fout(std::string n, std::string name)
{
std::ofstream cd(&name[0]);
cd << n;
cd.close();
return;
}
void fin(int& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(long long& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(bool& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(char& n, std::string name)
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
void fin(std::string& n, std::string name)//参考饼干369 
{
std::ifstream cd(&name[0]);
cd >> n;
cd.close();
return;
}
struct hl//行列
{
long long h, l;
};
hl where(bool x = 1, bool n = 1)//鼠标位置
{
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h = GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
hl hl;
POINT p;
if (x)
{
GetCursorPos(&p);
ScreenToClient(h, &p);
}
else
{
GetCursorPos(&p);
}
if (n)
{
GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
p.x /= consoleCurrentFont.dwFontSize.X;
p.y /= consoleCurrentFont.dwFontSize.Y;
}
hl.h = p.y + 1;
hl.l = p.x + 1;
return hl;
}
}
#endif

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值