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

Localisation Wrapper #663

Merged
merged 17 commits into from Jun 30, 2018

Conversation

Projects
None yet
5 participants
@jojolepro
Collaborator

jojolepro commented Apr 24, 2018

Wraps a localisation context in a Asset wrapper.
Slightly inconvenient to use because we have to wait for the asset to be loaded, but I'm not sure how to go around that.


This change is Reviewable

@torkleyy

I recommend you use Progress to wait for the asset and then place the locale context somewhere in the world.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Apr 26, 2018

Collaborator

Just realized I forget to rename things I copy pasted. Don't review now thanks ;)

Collaborator

jojolepro commented Apr 26, 2018

Just realized I forget to rename things I copy pasted. Don't review now thanks ;)

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 2, 2018

Collaborator

Fixing now...

Collaborator

jojolepro commented May 2, 2018

Fixing now...

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 2, 2018

Collaborator

Ready for review my dudes

Collaborator

jojolepro commented May 2, 2018

Ready for review my dudes

examples/locale/main.rs
+
+impl State for Example {
+ fn on_start(&mut self, world: &mut World) {
+ world.add_resource(AssetStorage::<Locale>::new());

This comment has been minimized.

@Rhuagh

Rhuagh May 2, 2018

Member

No longer needed, you add Processor<Locale> below, which will register this resource.

@Rhuagh

Rhuagh May 2, 2018

Member

No longer needed, you add Processor<Locale> below, which will register this resource.

This comment has been minimized.

@Rhuagh

Rhuagh May 12, 2018

Member

Ah, this is not fixed yet.

@Rhuagh

Rhuagh May 12, 2018

Member

Ah, this is not fixed yet.

This comment has been minimized.

@torkleyy

torkleyy May 28, 2018

Member

This should be using world.exec.

@torkleyy

torkleyy May 28, 2018

Member

This should be using world.exec.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 2, 2018

Collaborator

@torkleyy Its not useful in this case as ProgressCounter is made when batch loading multiple assets to prevent checking them one by one.

Collaborator

jojolepro commented May 2, 2018

@torkleyy Its not useful in this case as ProgressCounter is made when batch loading multiple assets to prevent checking them one by one.

examples/locale/main.rs
+ let store = world.read_resource::<AssetStorage<Locale>>();
+ // Check if the locale has been loaded.
+ // If you are doing this for multiple assets, you should be using `ProgressCounter`.
+ if let Some(locale) = store.get(&self.handle.clone().unwrap()) {

This comment has been minimized.

@torkleyy

torkleyy May 2, 2018

Member

Why are you cloning the handle?

@torkleyy

torkleyy May 2, 2018

Member

Why are you cloning the handle?

examples/locale/main.rs
+fn main() {
+ let resources_directory = format!("{}/examples/assets", env!("CARGO_MANIFEST_DIR"));
+ let mut game = Application::build(resources_directory, Example::new())
+ .expect("Fatal error")

This comment has been minimized.

@torkleyy

torkleyy May 2, 2018

Member

This should be using ? like the other examples.

@torkleyy

torkleyy May 2, 2018

Member

This should be using ? like the other examples.

amethyst_assets/src/asset.rs
@@ -3,6 +3,20 @@ use std::sync::Arc;
use amethyst_core::specs::storage::UnprotectedStorage;
#[cfg(feature = "profiler")]
#[macro_use]
+#[cfg(feature = "profiler")]

This comment has been minimized.

@Rhuagh

Rhuagh May 2, 2018

Member

Uuuh, wtf?

@Rhuagh

Rhuagh May 2, 2018

Member

Uuuh, wtf?

This comment has been minimized.

@jojolepro

jojolepro May 2, 2018

Collaborator

can I die?

@jojolepro

jojolepro May 2, 2018

Collaborator

can I die?

amethyst_assets/src/asset.rs
@@ -9,6 +9,14 @@ use amethyst_core::specs::storage::UnprotectedStorage;
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
+#[cfg(feature = "profiler")]

This comment has been minimized.

@torkleyy

torkleyy May 3, 2018

Member

I think one of these might be enough ;P

@torkleyy

torkleyy May 3, 2018

Member

I think one of these might be enough ;P

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 7, 2018

Member

Fix the conflicts and fix the review comment above and this is ready for merge.

Member

Rhuagh commented May 7, 2018

Fix the conflicts and fix the review comment above and this is ready for merge.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 7, 2018

Collaborator

#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
use thread_profiler::{register_thread_with_profiler, write_profile};

I'm rolling back the formatting changes.

Collaborator

jojolepro commented May 7, 2018

#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
use thread_profiler::{register_thread_with_profiler, write_profile};

I'm rolling back the formatting changes.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 7, 2018

Collaborator

Done

Collaborator

jojolepro commented May 7, 2018

Done

@torkleyy

Thanks for the fixes and cleanup, I have some more comments.

examples/locale/main.rs
+ let store = world.read_resource::<AssetStorage<Locale>>();
+
+ // Check if the locale has been loaded.
+ // If you are doing this for multiple assets, you should be using `ProgressCounter`.

This comment has been minimized.

@torkleyy

torkleyy May 7, 2018

Member

This example should show good practices, so please use the counter.

@torkleyy

torkleyy May 7, 2018

Member

This example should show good practices, so please use the counter.

examples/locale/main.rs
+ .context
+ .get_message("hello")
+ .and_then(|msg| locale.context.format(msg, None))
+ .unwrap()

This comment has been minimized.

@torkleyy

torkleyy May 7, 2018

Member

Should not use unwrap

@torkleyy

torkleyy May 7, 2018

Member

Should not use unwrap

@Moxinilian

How does one conveniently load and use multiple languages with this architecture?

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@Moxinilian

This comment has been minimized.

Show comment
Hide comment
@Moxinilian

Moxinilian May 10, 2018

Contributor

I've seen that already, and ironically enough I could not find anything about that.
Does that mean we have to create a Locale for every language? If so, that means we have to conditionally get the asset everywhere, right?

Contributor

Moxinilian commented May 10, 2018

I've seen that already, and ironically enough I could not find anything about that.
Does that mean we have to create a Locale for every language? If so, that means we have to conditionally get the asset everywhere, right?

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 12, 2018

Member

Conflictomania, but apart from that ready I believe?

Member

Rhuagh commented May 12, 2018

Conflictomania, but apart from that ready I believe?

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro May 12, 2018

Collaborator

Should be

Collaborator

jojolepro commented May 12, 2018

Should be

@torkleyy

Please add another language and address the comment, then we can merge this.

examples/locale/main.rs
+
+impl State for Example {
+ fn on_start(&mut self, world: &mut World) {
+ world.add_resource(AssetStorage::<Locale>::new());

This comment has been minimized.

@torkleyy

torkleyy May 28, 2018

Member

This should be using world.exec.

@torkleyy

torkleyy May 28, 2018

Member

This should be using world.exec.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 15, 2018

Collaborator

soon ™️

I know I say that often ;)

Collaborator

jojolepro commented Jun 15, 2018

soon ™️

I know I say that often ;)

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 15, 2018

Collaborator

Just updating the branch, will try to finish this thing this weekend. I'm not sure what changed last month so I don't know how much changes I need to make yet.

Collaborator

jojolepro commented Jun 15, 2018

Just updating the branch, will try to finish this thing this weekend. I'm not sure what changed last month so I don't know how much changes I need to make yet.

Cargo.toml
@@ -152,12 +152,17 @@ name = "appendix_a"
path = "examples/appendix_a/main.rs"
[[example]]
+<<<<<<< HEAD

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 15, 2018

Member

Woops, merge conflict merged

@Xaeroxe

Xaeroxe Jun 15, 2018

Member

Woops, merge conflict merged

@Rhuagh

Rhuagh approved these changes Jun 20, 2018

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 20, 2018

Collaborator

rustfmt pass 1 sec

Collaborator

jojolepro commented Jun 20, 2018

rustfmt pass 1 sec

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 20, 2018

Collaborator

Ready for merge yay. :D
@torkleyy can re-review if he wants to.

Collaborator

jojolepro commented Jun 20, 2018

Ready for merge yay. :D
@torkleyy can re-review if he wants to.

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 20, 2018

Collaborator

missing changelog entry

Collaborator

jojolepro commented Jun 20, 2018

missing changelog entry

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Jun 27, 2018

Collaborator

Ready for real now! (I totally forgot I had to update the changelog for a full week :P )

Collaborator

jojolepro commented Jun 27, 2018

Ready for real now! (I totally forgot I had to update the changelog for a full week :P )

@Xaeroxe

This looks great! Nicely done!

bors r+

bors bot added a commit that referenced this pull request Jun 30, 2018

Merge #663
663: Localisation Wrapper r=Xaeroxe a=jojolepro

Wraps a localisation context in a Asset wrapper.
Slightly inconvenient to use because we have to wait for the asset to be loaded, but I'm not sure how to go around that.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/663)
<!-- Reviewable:end -->


Co-authored-by: jojo <jojolepromain@gmail.com>
Co-authored-by: Joël Lupien (Jojolepro) <jojolepromain@gmail.com>
Co-authored-by: Joël Lupien <jojolepromain@gmail.com>
Co-authored-by: Jojolepro <jojolepromain@gmail.com>
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit e775ea3 into amethyst:develop Jun 30, 2018

3 checks passed

bors Build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jojolepro jojolepro deleted the jojolepro:locale branch Jun 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment