|
|
|
@ -102,11 +102,13 @@ int main(int argc, char *argv[]) {
@@ -102,11 +102,13 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
("s,server", "irc server address (irc.chat.twitch.tv)", cxxopts::value<std::string>()) |
|
|
|
|
("p,port", "irc server port (6667)", cxxopts::value<std::string>()) |
|
|
|
|
("b,background", "chat background colour (css format)", cxxopts::value<std::string>()) |
|
|
|
|
("width", "Window width", cxxopts::value<int>()) |
|
|
|
|
("height", "Window height", cxxopts::value<int>()) |
|
|
|
|
("m,max-age", "Maximum age of a displayed message", cxxopts::value<int>()) |
|
|
|
|
("F,foregreound", "text colour (css format)", cxxopts::value<std::string>()) |
|
|
|
|
("h,help", "Print help") |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto result = options.parse(argc, argv); |
|
|
|
|
if (result.count("help")) { |
|
|
|
|
std::cout << options.help() << std::endl; |
|
|
|
@ -138,13 +140,30 @@ int main(int argc, char *argv[]) {
@@ -138,13 +140,30 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
maxfps = result["fps"].as<int>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int height = 480; |
|
|
|
|
int width = 640; |
|
|
|
|
|
|
|
|
|
if (result.count("width")) { |
|
|
|
|
width = result["width"].as<int>(); |
|
|
|
|
} |
|
|
|
|
if (result.count("height")) { |
|
|
|
|
height = result["height"].as<int>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
drawinfo info {}; |
|
|
|
|
info.drawcontext = create_window(640, 480, "Twitch chat " + channel); |
|
|
|
|
std::string window_title = "Twitch chat " + channel; |
|
|
|
|
std::stringstream s {}; |
|
|
|
|
s << window_title + " " << width << "x" << height; |
|
|
|
|
info.max_age = 30000; // messages disappear after 30 seconds
|
|
|
|
|
info.drawcontext = create_window(width, height, s.str()); |
|
|
|
|
info.fonts = load_fonts(); |
|
|
|
|
info.colours.background = { 230, 230, 230, 255 }; |
|
|
|
|
info.colours.messages = { 255, 255, 255, 255 }; |
|
|
|
|
|
|
|
|
|
if (result.count("max-age")) { |
|
|
|
|
info.max_age = result["max-age"].as<int>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.count("background")) { |
|
|
|
|
auto bg = CSSColorParser::parse(result["background"].as<std::string>()); |
|
|
|
|
if (bg) { |
|
|
|
@ -180,6 +199,10 @@ int main(int argc, char *argv[]) {
@@ -180,6 +199,10 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
if (delay > 0) SDL_Delay(delay); |
|
|
|
|
prev = now; |
|
|
|
|
|
|
|
|
|
if (now % 5000) { |
|
|
|
|
new_message = true; // trigger an occasional full redraw
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto resp = readresponsenonblock(sock); |
|
|
|
|
if (resp) { |
|
|
|
|
new_message = true; |
|
|
|
@ -188,6 +211,7 @@ int main(int argc, char *argv[]) {
@@ -188,6 +211,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
while (SDL_PollEvent(&event)) { |
|
|
|
|
std::stringstream s{}; |
|
|
|
|
switch (event.type) { |
|
|
|
|
case SDL_QUIT: |
|
|
|
|
return 0; |
|
|
|
@ -200,6 +224,9 @@ int main(int argc, char *argv[]) {
@@ -200,6 +224,9 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
case SDL_WINDOWEVENT_SIZE_CHANGED: |
|
|
|
|
info.drawcontext.width = event.window.data1; |
|
|
|
|
info.drawcontext.height = event.window.data2; |
|
|
|
|
s << window_title;
|
|
|
|
|
s << " " << info.drawcontext.width << "x" << info.drawcontext.height; |
|
|
|
|
SDL_SetWindowTitle(info.drawcontext.win, s.str().c_str()); |
|
|
|
|
new_message = true; // trigger redraw
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|