代码拉取完成,页面将自动刷新
同步操作将从 HellTractor/字符电脑 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//v0.1 2021.9.11
//v0.2 2021.9.12 窗口可以移动
//v1.0 2021.9.19 优化输出算法、单个应用可以正常运行
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<unistd.h>
using namespace std;
int HANG=40,LIE=150;
const int MAXN=500;//数组规格
int hdcolor=0;//彩色
string performance="low";//性能
char ctable[MAXN][MAXN]={};
char empty[100][MAXN][MAXN]={};//app[i]的白板
int waop=0;
int maincourse();
int main();
int table();
int open(int n);
int tabbar();
int appbar();
int contbar();
int click(int x,int y);
inline void gotoxy(short x, short y) {
COORD coord = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
int nowapp=0;
//顶部状态栏
char tabline[MAXN]={};
void printtab(int lie=LIE){
for(int i=0;i<strlen(tabline);i++){
tabline[i]=' ';
}
string strtab="| TAB | 1.开始";
for(int i=1;i<=lie-60;i++){
strtab=strtab+" ";
}
strtab=strtab+"2.应用 3.控制中心 4.取消 | ESC 返回桌面 |";
for(int i=0;i<strtab.length();i++){
tabline[i]=strtab[i];
}
}
void print(char ch[][MAXN],int m,int n,int x,int y,int fx=0,int fy=0/*输出边界*/){
if(!hdcolor)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),224);
gotoxy(x,y);
for(int i=fx;i<m+fx;i++){
for(int j=fy;j<n+fy;j++){
if(hdcolor && (ch[i][j]=='-' || ch[i][j]=='|' || ch[i][j]=='+')){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),17);
cout<<" ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),224);
}
else {
cout<<ch[i][j];
}
}
gotoxy(x,++y);
//cout<<endl;
}
}
struct appinfo{//68
bool developed=0;//是否已被开发
bool open=0;//是否已被打开
bool dowloaded=0;//是否被安装
int x=13,y=5;//窗口位置
int x1=0,y1=2;
string schedule="home";//app进度
string appname="ERROR";
int hang=HANG/2,lie=LIE/2;
int hang1=HANG-2,lie1=LIE;
char frame[MAXN][MAXN]={};
int fx=0,fy=0;//输出上边界
bool fullscreen=0;
void screenchange(){
int tx=x,ty=y,thang=hang,tlie=lie;
x=x1,y=y1,hang=hang1,lie=lie1;
x1=tx,y1=ty,hang1=thang,lie1=tlie;
}
};
appinfo apps[100];
appinfo sysapps[100];
inline void printempty(int n=nowapp){
print(empty[n],apps[n].hang-5,apps[n].lie-2,apps[n].x+1,apps[n].y+3,apps[n].fx,apps[n].fy);
}
char readc(){
if(waop!=0){
int x=waop;
waop=0;
open(x);
return ' ';
}
char ch=getch();
if(ch==9){//tab 点击后跳转到系统菜单
tabbar();
}
else if(ch==27){//esc跳转桌面
nowapp=0;
table();
exit(0);
}
return ch;
}
string reads(){
char ch;
string str;
int str_=0;
while(ch!=13){
ch=readc();
if(ch==8){
cout<<"\b \b";
str[--str_]=' ';
}
else{
cout<<ch;
str[str_++]=ch;
}
if(ch==13)break;
}
return str;
}
void addicon(char icon[][MAXN],char obj[][MAXN],int m/*icon行数*/,int x,int y){
for(int i=0;i<m;i++){
for(int j=0;j<strlen(icon[i]);j++){
obj[x][y+j]=icon[i][j];
}
x++;
}
}
void addnum(int icon[][MAXN],int obj[][MAXN],int m,int n,int x,int y){
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
obj[x][y+j]=icon[i][j];
}
x++;
}
}
void addstr(string icon,char obj[][MAXN],int x,int y){
for(int i=0;i<icon.length();i++){
obj[x][y++]=icon[i];
}
}
void paintframe(int nowapp){
int hang=apps[nowapp].hang;int lie=apps[nowapp].lie;
for(int i=0;i<hang;i++){//行
for(int j=0;j<lie;j++){//列
apps[nowapp].frame[i][j]=' ';
if(i==0 || i==hang-1)apps[nowapp].frame[i][j]='-';
if(i==2 || i==hang-1)apps[nowapp].frame[i][j]='-';
if(j==0 || j==lie-1)apps[nowapp].frame[i][j]='|';
if(i==hang-1 && j==lie-1)apps[nowapp].frame[i][j]='+';
if(i==0 && j==lie-1)apps[nowapp].frame[i][j]='+';
if(i==hang-1 && j==0 )apps[nowapp].frame[i][j]='+';
if(i==0 && j==0 )apps[nowapp].frame[i][j]='+';
if(i==2 && j==0 )apps[nowapp].frame[i][j]='+';
if(i==2 && j==lie-1)apps[nowapp].frame[i][j]='+';
}
}
for(int j=0;j<apps[nowapp].appname.length();j++){
apps[nowapp].frame[1][j+2]=apps[nowapp].appname[j];
}
}
inline void printframe(int n=nowapp){
print(apps[n].frame,apps[n].hang,apps[n].lie,apps[n].x,apps[n].y);
}
void stable(){//初始化桌面
int n=LIE,m=HANG;//n 列 m 行
for(int i=0;i<m;i++){//行
for(int j=0;j<n;j++){//列
ctable[i][j]=' ';
if(i==0 || i==m-1)ctable[i][j]='-';
if(i==2 || i==m-1)ctable[i][j]='-';
if(j==0 || j==n-1)ctable[i][j]='|';
if(i==m-1 && j==n-1)ctable[i][j]='+';
if(i==0 && j==n-1)ctable[i][j]='+';
if(i==m-1 && j==0 )ctable[i][j]='+';
if(i==0 && j==0 )ctable[i][j]='+';
if(i==2 && j==0 )ctable[i][j]='+';
if(i==2 && j==n-1)ctable[i][j]='+';
}
}
int X=3,Y=3;
int x=X,y=Y;//软件位置编号
char icon[10][MAXN]={
{"+----+"},
{"| |"},
{"+----+"}
};
for(int i=0;i<100;i++){
if(apps[i].dowloaded){
addicon(icon,ctable,3,x,y); //绘制图标
ctable[x+1][y+2]=(i/10)+'0';//容纳两位数
ctable[x+1][y+3]=(i%10)+'0';
for(int j=0;j<apps[i].appname.length();j++){
ctable[x+3][y+j]=apps[i].appname[j];
}
x+=5;
if(x>=30){
x=X;
y+=10;
}
}
}
addstr(tabline,ctable,1,0);
}
void freashempty(int n=nowapp){
for(int i=0;i<MAXN;i++){
for(int j=0;j<MAXN;j++){
empty[n][i][j]=' ';
}
}
}
void printagain(int showapp=1){
system("cls");
print(ctable,HANG,LIE,0,0);
for(int i=0;i<100;i++){
if(!apps[i].fullscreen &&showapp && apps[i].open){
printframe(i);
printempty(i);
}
}
}
void setting(string schedule=apps[1].schedule){//apps[1];
apps[1].open=1;
int hang=apps[1].hang,lie=apps[1].lie;
int x=apps[1].x,y=apps[1].y;
freashempty();
//gotoxy(apps[1].x,apps[1].y);//这是一条定位示例
if(schedule=="home"){
char homei[4][MAXN]={
{"+-------------+ +-------------+"},
{"| 1> 关于系统 | | 2> 显示 |"},
{"+-------------+ +-------------+"},
};
addicon(homei,empty[1],3,1,1);
printempty();
char ch=readc();
if(ch=='1'){
apps[1].schedule="about";
return;
}
else if(ch=='2'){
apps[1].schedule="show";
return;
}
apps[1].schedule="home";
}
else if(schedule=="about"){
char abouti[10][MAXN]={
{"+--------------------------------------------------+"},
{"| v1.5.0 2021.10.5 支持了全屏 按任意键返回 |"},
{"+--------------------------------------------------+"},
};
addicon(abouti,empty[1],3,1,1);
printempty();
char ch=readc();
apps[1].schedule="home";
return;
}
else if(schedule=="show"){//显示
char showi[4][MAXN]={
{"+------------------+ +--------------+ +--------+"},
{"| 1> 显示质量: | | 2> 颜色 | |3> 返回 |"},
{"+------------------+ +--------------+ +--------+"},
};
addstr(performance,showi,1,14);
addstr(to_string(hdcolor),showi,1,37);
addicon(showi,empty[1],3,1,1);
printempty();
char ch=readc();
if(ch=='1'){
if(performance=="high"){
performance="low";
}
else{
performance="high";
}
}
else if(ch=='2'){
hdcolor=1-hdcolor;
printagain(1);
}
else{
apps[1].schedule="home";
}
return;
}
return;
}
void appst(string schedule=apps[2].schedule){//apps[2];
freashempty();
apps[2].open=1;
int hang=apps[2].hang,lie=apps[2].lie;
if(schedule=="home"){
char icon[40][MAXN]={
{"+点击序号以操作------------+"},
{"| |"},
{"+--------------------------+"},
};
int x=1,y=1;//位置编号
for(int i=0;i<100;i++){
if(apps[i].developed){
addicon(icon,empty[2],3,x,y);
string str=to_string(i)+"> "+apps[i].appname;
addstr(str,empty[2],x+1,y+1);
if(y==1){
y+=35;
}
else{
y=1;x+=4;
}
}
}
printempty();
string str=reads();
int n=stoi(str);
if(apps[n].developed){
apps[n].dowloaded=1-apps[n].dowloaded;
apps[n].open=0;
apps[n].schedule="home";
stable();
printagain();
}
}
return;
}
int start();
tabbar(){
gotoxy(0,1);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),240);
for(int i=0;i<strlen(tabline);i++){
cout<<tabline[i];
if(i%10==0)usleep(1000);
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
char temp=readc();
if(temp=='1'){
start();
}
else if(temp=='2'){
appbar();
}
else if(temp=='3'){
contbar();
}
else if(temp=='4'){
}
else if(temp==32){//对当前应用进行操作
}
else{
}
gotoxy(0,1);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
for(int i=0;i<strlen(tabline);i++){
cout<<tabline[i];
if(i%10==0)usleep(1000);
}
return 0;
}
start(){
int x=5,y=3;
char cb[100][MAXN]={
{"+--------------------+"},
{"| |"},
{"| +----------------+ |"},
{"| | 1> 退出 | |"},
{"| +----------------+ |"},
{"| |"},
{"+--------------------+"},
};
print(cb,7,22,x,y);
char t=readc();
if(t=='1'){
exit(0);
}
}
contbar(){
int x=110,y=3;
char cb[100][MAXN]={
{"+--------------------+"},
{"| |"},
{"| +----------------+ |"},
{"| | 1> 全刷 | |"},
{"| +----------------+ |"},
{"| |"},
{"+--------------------+"},
};
print(cb,7,22,x,y);
char t=readc();
if(t=='1'){
printagain(nowapp);
}
}
appbar(){
if(!(0<nowapp<100)){
return 0;
}
int x=LIE-50,y=3;
char cb[100][MAXN]={
{"+--------------------+"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"| |"},
{"+--------------------+"},
};
print(cb,13,22,x,y);
gotoxy(x+2,y+1);cout<<"当前应用:"<<apps[nowapp].appname;
gotoxy(x+2,y+3);cout<<"a.更改窗口位置";
gotoxy(x+2,y+5);cout<<"b.关闭应用";
gotoxy(x+2,y+7);cout<<"c.翻页";
if(apps[nowapp].fullscreen){
gotoxy(x+2,y+9);cout<<"d.向下还原";
}
else{
gotoxy(x+2,y+9);cout<<"d.全屏";
}
char t=readc();
if(t=='a'){
print(cb,13,22,x,y);
gotoxy(x+2,y+1);cout<<"wasd操控 空格结束";
while(1){
t=readc();
if(t=='a'){
apps[nowapp].x--;
}
if(t=='w'){
apps[nowapp].y--;
}
if(t=='s'){
apps[nowapp].y++;
}
if(t=='d'){
apps[nowapp].x++;
}
if(t==32){
print(ctable,40,150,0,0);
open(nowapp);
maincourse();
exit(0);
}
printframe();
}
}
else if(t=='b'){
apps[nowapp].schedule="home";
apps[nowapp].open=0;
apps[nowapp].fx=0;
apps[nowapp].fy=0;
printagain(1);
return 0;
}
else if(t=='c'){
print(cb,13,22,x,y);
if(nowapp>0 && apps[nowapp].dowloaded){
gotoxy(x+2,y+7);cout<<"ws操控 空格结束";
}
else{
gotoxy(x+2,y+7);cout<<"请先选中一个应用";
return 0;
}
while(1){
t=readc();
if(t==32){
print(ctable,40,150,0,0);
open(nowapp);
maincourse();
exit(0);
}
if(t=='w'){
if(apps[nowapp].fx>0)
apps[nowapp].fx--;
printempty();
}
else if(t=='s'){
apps[nowapp].fx++;
printempty();
}
}
}
else if(t=='d'){
apps[nowapp].fullscreen=1-apps[nowapp].fullscreen;
apps[nowapp].screenchange();
printagain();
open(nowapp);
exit(0);
}
return 0;
}
void registry(){//app注册表
apps[0].appname="system";
apps[1].developed=1;
apps[1].appname="设置";
apps[1].dowloaded=1;
apps[2].developed=1;
apps[2].appname="应用商店";
apps[2].dowloaded=1;
for(int i=3;i<=30;i++){
apps[i].developed=1;
apps[i].appname="体验翻页功能";
}
}
int starter(){
cout<<"配置\n\n分辨率\n";
cout<<"1.默认 2.自定义";
char ch=getch();
if(ch=='1'){
return 0;
}
else{
system("cls");
cout<<"\n行数(默认:"<<HANG<<"):";
cin>>HANG;
cout<<"\n列数(默认:"<<LIE<<"):";
cin>>LIE;
}
return 0;
}
void open(int n){
if(n==0)return 0;
if(apps[n].developed && apps[n].dowloaded){//应用
for(int i=0;i<100;i++){
if(apps[i].open && i!=n && !apps[i].fullscreen){//窗口堆叠
if(apps[i].x==apps[n].x && apps[i].y==apps[n].y)continue;
printframe(i);
printempty(i);
}
}
apps[n].open=1;
while(apps[n].open){
paintframe(n);
printframe(n);
switch (n) {
case 1: setting();break;
case 2: appst();break;
default:
apps[n].open=0;
apps[n].developed=0;
apps[n].dowloaded=0;
stable();
table();
exit(0);
break;
}
}
}
else {//系统函数
if(n==-1){
tabbar();
}
}
}
void table(){
nowapp=0;
print(ctable,HANG,LIE,0,0);
while(1){
int f=1;
for(int i=10;i<100;i++){
if(apps[i].dowloaded){
f=0;break;
}
}
if(!f){
string str=reads();
nowapp=stoi(str);
if(nowapp>100){
continue;
}
open(nowapp);
}
else{
char ch=readc();
nowapp=ch-'0';
open(nowapp);
}
}
}
void maincourse(){
nowapp=0;
printtab();//绘制tabline
registry();//载入注册表
stable();//绘制ctable
table();//桌面程序
}
void main(){
starter();
maincourse();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。