Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay roster picture display and other stuff #173

Merged
merged 44 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f2d25bf
random improvements
actuday6418 Jun 2, 2023
7afb208
random improvements
actuday6418 Jun 2, 2023
8c93f23
update dependencies, load images
actuday6418 Jun 5, 2023
6fb955f
basic rpd page
actuday6418 Jun 10, 2023
97de9b4
retry if request fails
actuday6418 Jun 10, 2023
b25df02
little refactor
actuday6418 Jun 11, 2023
2552b4c
basic implementation of all rpd features. other random changes lost t…
actuday6418 Jun 22, 2023
551f70b
remove unnecessary images
actuday6418 Jun 22, 2023
7c7cb2d
add ellipses when truncating text
actuday6418 Jun 26, 2023
6205873
equally spaced cards in rpd, preferring arrangement of 4s and 3s
actuday6418 Jun 26, 2023
2a7a003
remove animation of time and state graphic in game
actuday6418 Jun 26, 2023
6ec74fe
remove animation of time and state graphic in game
actuday6418 Jun 26, 2023
6ac70ce
small refactor, new rpd textures, better network performance
actuday6418 Jul 1, 2023
396a413
updated graphics, placement and text fitting, improved code readabili…
actuday6418 Jul 8, 2023
4145fae
revert gid and tid, remove background image
actuday6418 Jul 10, 2023
e800ae2
Merge branch 'master' into master
actuday6418 Jul 10, 2023
1dab1fa
resolve cargo.lock merge conflict
actuday6418 Jul 10, 2023
6ad780a
tournament logo changes from upstream
actuday6418 Jul 12, 2023
ff71c88
merge 5 upstream commits
actuday6418 Jul 12, 2023
beb4e2d
prefetch next game data
actuday6418 Jul 15, 2023
b8f84be
clippy
actuday6418 Jul 15, 2023
ca9f63a
new api for team data
actuday6418 Jul 15, 2023
800445b
clippy
actuday6418 Jul 15, 2023
4ba8c8b
more clippy
actuday6418 Jul 15, 2023
4662457
separate uwhscores and uwhportal links
TristanDebrunner Nov 10, 2023
ffa9d5c
Merge pull request #1 from TristanDebrunner/overlay-testing
actuday6418 Nov 18, 2023
df146db
Merge branch 'AtlantisSports:master' into master
actuday6418 Nov 18, 2023
ccd8728
Misc improvements and react changes to tournament ID
actuday6418 Nov 20, 2023
ed23267
make network calls concurrent
actuday6418 Nov 20, 2023
b7d37c5
Skip sections of rpd when no data is present, Fix quotes in text, Cor…
actuday6418 Nov 26, 2023
ec0c2b5
skip rpd section if there are no images to display
actuday6418 Nov 28, 2023
3c77155
cargo clippy
actuday6418 Nov 28, 2023
32dd00b
fetch next game data if tid changes
actuday6418 Nov 28, 2023
613d21c
typo
actuday6418 Nov 28, 2023
46f1e93
reduce height of each row in roster list by 2 pixels
actuday6418 Dec 2, 2023
3a41481
show old game's results if is_old_game is still true
actuday6418 Dec 2, 2023
748ac57
show old game's results if is_old_game is still true
actuday6418 Dec 2, 2023
819515f
fix issues with game data caching and reacting to tid changes
actuday6418 Dec 2, 2023
9a1f65d
Merge branch 'master' into tmep
actuday6418 Dec 3, 2023
5762c38
restore lock file
actuday6418 Dec 3, 2023
ab70878
improve some variable naming
actuday6418 Dec 5, 2023
903be97
check for updates to `next_game_number` each snapshot
actuday6418 Dec 6, 2023
e4651b4
don't invalidate cache
actuday6418 Dec 6, 2023
1b71c4f
Only request the same information once
TristanDebrunner Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 210 additions & 110 deletions Cargo.lock

Large diffs are not rendered by default.

951 changes: 951 additions & 0 deletions alphagen/Cargo.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions alphagen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
name = "alphagen"
version = "0.1.0"
edition = "2021"
description = "Used to generate greyscale mask images based on the alpha channel of existing images"
description = "Used to generate greyscale mask images based on the alpha channel of an image"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4", features = ["derive"] }
image = "*"
clap = { version = "4.3.0", features = ["derive"] }
image = "0.24.6"
log = "0.4.18"
pretty_env_logger = "0.5.0"
rayon = "*"

[lib]
name = "alphagen"
21 changes: 21 additions & 0 deletions alphagen/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# AlphaGen

AlphaGen is a small Rust application used to generate greyscale mask images based on the alpha channel of an image. It takes input image files and an output directory as command-line arguments and processes the images in parallel to generate greyscale mask images.

## Usage

```shell
alphagen input_file(s) output_directory
```

### Installation

To use AlphaGen, you need to have Rust and Cargo installed. If you don't have them installed, you can follow the official Rust installation guide: https://www.rust-lang.org/tools/install

Once Rust is installed, you can clone the project repository and navigate to the project directory:

```shell
git clone <repository-url>
cd alphagen
cargo install --path .
```
51 changes: 51 additions & 0 deletions alphagen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use image::io::Reader;
use image::GenericImageView;
use image::ImageFormat;
use rayon::iter::ParallelBridge;
use rayon::iter::ParallelIterator;
use std::fs;
use std::io::BufWriter;
use std::io::Cursor;
use std::path::PathBuf;

/// Processes all files in `paths` and writes output images to `dir_output`
pub fn on_paths(paths: Vec<&PathBuf>, dir_output: PathBuf) {
paths.iter().par_bridge().for_each(|path| {
let file = image::open(path).unwrap();
let mut output_image_buff = image::GrayAlphaImage::new(file.width(), file.height());
let mut pixs = output_image_buff.pixels_mut();
let mut file_out = fs::File::create(dir_output.join(path.file_name().unwrap()))
.expect("Couldn't create output file");
for (_, _, alpha_channel) in file.pixels() {
let p = pixs.next().unwrap();
p.0[0] = alpha_channel[3];
p.0[1] = alpha_channel[3];
}
output_image_buff
.write_to(&mut file_out, image::ImageFormat::Png)
.unwrap_or_else(|_| {
panic!(
"Couldn't write to output directory {}/{:?}",
dir_output.display(),
path.file_name().unwrap_or_default()
)
});
});
}

/// Process raw image data
pub fn on_raw(input: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
let img_in = Reader::new(Cursor::new(input))
.with_guessed_format()?
.decode()?;
let mut img_out = image::GrayAlphaImage::new(img_in.width(), img_in.height());
let mut pixs = img_out.pixels_mut();
for (_, _, alpha_channel) in img_in.pixels() {
let p = pixs.next().unwrap();
p.0[0] = alpha_channel[3];
p.0[1] = alpha_channel[3];
}
let mut writer = BufWriter::new(Cursor::new(Vec::new()));
img_out.write_to(&mut writer, ImageFormat::Png)?;
Ok(writer.into_inner()?.into_inner())
}
74 changes: 27 additions & 47 deletions alphagen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
use alphagen::on_paths;
use clap::Parser;
use image::GenericImageView;
use log::warn;
use rayon::iter::ParallelBridge;
use rayon::iter::ParallelIterator;
use std::{fs, path::PathBuf};
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(long, short, required = true)]
/// Directory within which to find the color images
path: PathBuf,
#[command(author, version, about)]
struct Args {
#[clap(help = "Input files", required = true)]
input_location: Vec<PathBuf>,

#[clap(long, short)]
/// Output directory for the alpha images
out: Option<PathBuf>,
#[clap(help = "Output directory", required = true)]
output_location: PathBuf,
}

fn main() {
let args = Cli::parse();
pretty_env_logger::init();
let args = Args::parse();

if let Some(ref out) = args.out {
if out == &args.path {
println!("Error: if the <out> arg is specified, it cannot match the <path> arg");
return;
}
assert!(out.is_dir());
let dir_output = args.output_location;
if !dir_output.is_dir() {
std::fs::create_dir_all(&dir_output).expect("Could not create output directory!");
}

assert!(args.path.is_dir());

let append_alpha = args.out.is_none();
let out_dir = args.out.as_ref().unwrap_or(&args.path).to_path_buf();

let input_paths = fs::read_dir(args.path).unwrap();

input_paths.par_bridge().for_each(|path| {
if let Ok(path) = path {
let file_name: String = path.path().file_stem().unwrap().to_str().unwrap().into();
let file = image::open(path.path()).unwrap();

let mut imgbuf = image::GrayAlphaImage::new(file.width(), file.height());
let mut pixs = imgbuf.pixels_mut();

let mut out_path = out_dir.clone();
out_path.push(if append_alpha {
format!("{file_name}_alpha.png")
let paths = args
.input_location
.iter()
.par_bridge()
.filter(|p| {
if p.is_file() {
true
} else {
format!("{file_name}.png")
});
let fout = &mut fs::File::create(out_path).unwrap();

for pixel in file.pixels() {
let p = pixs.next().unwrap();
p.0[0] = pixel.2[3];
p.0[1] = pixel.2[3];
warn!("{} is not a valid file path. Skipping.", p.display());
false
}
})
.collect::<Vec<_>>();

imgbuf.write_to(fout, image::ImageFormat::Png).unwrap();
println!("Completed: {}", path.path().to_str().unwrap());
}
});
assert!(paths.is_empty(), "No valid input file paths!");
on_paths(paths, dir_output);
}
22 changes: 12 additions & 10 deletions overlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4", features = ["derive"] }
coarsetime = "*"
clap = { version = "4.3.1", features = ["derive"] }
futures = "0.3"
coarsetime = "0.1.23"
confy = "0.5"
crossbeam-channel = "*"
directories = "5"
image = { version = "*", features = ["png", "jpeg"] }
log = "*"
crossbeam-channel = "0.5.8"
directories = "5.0.1"
log = "0.4.18"
log-panics = { version = "2", features = ["with-backtrace"]}
log4rs = { version = "1", default-features = false, features = ["background_rotation", "compound_policy", "console_appender", "fixed_window_roller", "gzip", "pattern_encoder", "rolling_file_appender", "size_trigger"]}
macroquad = { version = "0.3", default-features = false }
pollster = "*"
reqwest = { version = "*", features = ["blocking"] }
reqwest = {version = "0.11", features = ["gzip"]}
serde = { version = "1", features = ["derive"] }
serde_json = { version = "*" }
tokio = { version = "*", features = ["macros"] }
serde_json = { version = "1" }
tokio = { version = "1.28", features = ["full"] }
uwh-common = { path = "../uwh-common/" }
bytes = "1.4.0"
alphagen = {path="../alphagen"}
image = { version = "0.24", default-features = false, features = ["png", "jpeg_rayon"] }
Binary file modified overlay/assets/alpha/1080/Atlantis Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added overlay/assets/alpha/1080/Black Team Name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Black Timeout Flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Final Score.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added overlay/assets/alpha/1080/Number Background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Penalty Black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Penalty Shot Flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Penalty White.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added overlay/assets/alpha/1080/Red Team Name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified overlay/assets/alpha/1080/Referee Timeout Flag.png
Binary file modified overlay/assets/alpha/1080/Team Bars.png
Binary file modified overlay/assets/alpha/1080/Team Black.png
Binary file modified overlay/assets/alpha/1080/Team Information.png
Binary file modified overlay/assets/alpha/1080/Team White.png
Binary file modified overlay/assets/alpha/1080/Time and Game State.png
Binary file added overlay/assets/alpha/1080/White Team Name.png
Binary file modified overlay/assets/alpha/1080/White Timeout Flag.png
Binary file removed overlay/assets/alpha/1080/mask.png
Diff not rendered.
Binary file added overlay/assets/color/1080/Black Team Name.png
Binary file added overlay/assets/color/1080/Number Background.png
Binary file added overlay/assets/color/1080/Red Team Name.png
Binary file added overlay/assets/color/1080/White Team Name.png
Binary file removed overlay/assets/color/1080/mask.png
Diff not rendered.
Loading