如何制作C++菜单文本
How to make C++ menu text
我正在制作一款基于文本的冒险游戏。我想让游戏名称(被困)大或由线条组成。我该怎么做?
我想要的一个例子是这样的:
╔═╗╔═╗───╔╗──────╔╗────╗─╔╗──╃╗──╗╔╗╗╃╗────╔═══╦╗ ║║╚╝║║───║║────────║║────║║─║║──║║║║────╚╗╔╗║║ ║╔╗╔╗╠══╦╣║╔╦══╦╗─╔╣║╔══╗║╚═╝╠══╣║║║╔══╗─║║║║╚═╦══╦══╦══╗* ║║║║║║╔╗╠╣╚╝╣╔╗║║─║║║║╔╗║║╔═╗║║═╣║║║║╔╗║─║║║║╔╗║╔╗║╔╗║║═╣ ║║║║║║╔╗║║╔╗╣╔╗║╚═╝║╚╣╔╗║║║─║║║═╣╚╣╚╣╔╗║╔╝╚╝║║║║╚╝║╚╝║║═╣ ╚╝╚╝╚╩╝╚╩╩╝╚╩╝╚╩═╗╔╩═╩╝╚╝╚╝─╚╩══╩═╩═╩╝╚╝╚═══╩╝╚╩══╣╔═╩══╝ ───────────────╔═╝║───────────────────────────────║║ ──────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
但更明显。而且当它被编译时,它会在?
的中出现。 所以我需要文本对编译器友好。
在 Windows 上,使用宽字符串文字:
wchar_t * titleStr= L"╔═╗╔═╗───╔╗────────╔╗────╔╗─╔╗──╔╗╔╗────╔═══╦╗n"
L"║║╚╝║║───║║────────║║────║║─║║──║║║║────╚╗╔╗║║n"
L"║╔╗╔╗╠══╦╣║╔╦══╦╗─╔╣║╔══╗║╚═╝╠══╣║║║╔══╗─║║║║╚═╦══╦══╦══╗*n"
L"║║║║║║╔╗╠╣╚╝╣╔╗║║─║║║║╔╗║║╔═╗║║═╣║║║║╔╗║─║║║║╔╗║╔╗║╔╗║║═╣ n"
L"║║║║║║╔╗║║╔╗╣╔╗║╚═╝║╚╣╔╗║║║─║║║═╣╚╣╚╣╔╗║╔╝╚╝║║║║╚╝║╚╝║║═╣ n"
L"╚╝╚╝╚╩╝╚╩╩╝╚╩╝╚╩═╗╔╩═╩╝╚╝╚╝─╚╩══╩═╩═╩╝╚╝╚═══╩╝╚╩══╣╔═╩══╝ n"
L"───────────────╔═╝║───────────────────────────────║║ n"
L"───────────────╚══╝───────────────────────────────╚╝n"
std::wcout<<titleStr;
有多种方法可以做到这一点。
最简单的方法是在此处使用 cout (char)
ASCII 字符及其代码的列表 http://www.cplusplus.com/doc/ascii/。
您还可以尝试将所有文本转储到单独的文本文件中,读取并解析该文件,然后将其打印到控制台。
像这样:
#include <iostream>
#include <fstream>
#include <string>
int main() {
std::ifstream reader("art.txt"); //Load the text
std::string art = parseart(reader); //Parse the file
std::cout << art << std::endl; //Print
reader.close();
return 0;
}
std::string parseart(std::ifstream& File) {
std::string parsedfile;
if(File) {
while(File.good()) {
std::string tmpline;
std::getline(File, tmpline);
tmpline += "n";
parsedfile += tmpline;
}
return parsedfile;
} else {
//Error
}
相关文章:
- 文本文件中的单词链表
- 从命令行c++发送文本文件名
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 2D数组来自文本输入,中间有空格
- 如何将内容数组写入文本文件?
- 无法通过空白将文本文件行分隔为矢量
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- C++将文本文件中的数据读取到结构数组中
- 在指针的帮助下,文本文件中单词的频率
- 如何使用IExecuteCommand和动词在上下文菜单外壳扩展中显示本地化文本和自定义图标?
- 如何在OpenGL菜单系统中实现文本的智能渲染
- 如何制作C++菜单文本
- 使用矢量、字符串和数组创建菜单,同时读取2个文本文件
- 用于显示文本模式菜单的库
- opengl在屏幕菜单上打印文本变量
- Linux上基于C++文本的选择菜单的行为很奇怪
- 更改菜单项的文本
- 如何更改菜单项文本
- 如何在MFC功能包应用程序中禁用菜单栏项中的文本恢复
- 如何动态更新QMenu和子菜单标题文本