前三章完成了唐诗的应用,本章将实现宋词的学习应用。
宋词与唐诗的区别不大,马上开始。
1、我们需要参考前面唐诗的方式,把宋词文本下载下来,并进行格式整理。
W801学习笔记十七:古诗学习应用——上
2、在菜单中添加宋词选项
[{"t": "三分钟限时挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":1, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":1, "m":2},"s": []}]}]},{"t": "五十题竞速挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":2, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":2, "m":2},"s": []}]}]},{"t": "零错误闯关挑战","i": "-","d": 0,"g": {},"s": [{"t": "语文","i": "menu/yuwen.png","d": 0,"g": {},"s": [{"t": "唐诗三百首","i": "-","d": 302,"g": {"w":3, "m":1},"s": []},{"t": "宋词三百首","i": "-","d": 302,"g": {"w":3, "m":2},"s": []}]}]},{"t": "关于","i": "menu/test16.png","d": 102,"g": {},"s": []}
]
我们在g属性中,添加m属性,用于标识是唐诗还是宋词
3、在初始化中添加宋词数据的加载
int YuWenTS::scean_init(cJSON* param){
。。。winMode= cJSON_GetObjectItem(param,"w")->valueint;gameMode = cJSON_GetObjectItem(param,"m")->valueint;printf("start chinese. winMode=%d, gameMode=%d.\n", winMode, gameMode);switch (gameMode) {case 1: // 唐诗300fatfs_readFile("project/tangshi300gb.txt", &DataBuff);fatfs_readFile("project/tangshi300index.txt", &DataBuffIndex);YuWenCount = dataLineIdx(-1);YuWenItemCount= dataLineCount(-1);break;case 2: // 宋词300fatfs_readFile("project/songci300gb.txt", &DataBuff);fatfs_readFile("project/songci300index.txt", &DataBuffIndex);YuWenCount = dataLineIdx(-1);YuWenItemCount= dataLineCount(-1);break;}start();return 0;
}
似乎不需要做什么事情就结束了。大部分的精力,都耗费在了格式的整理上。
按照同样的道理,还可以继续对诗经等内容进行扩展,这里就不再赘述了。